jazzy
05/15/2021, 3:46 PM{
"type": "STATE",
"value": {
"bookmarks": {
"orders": {
"progress_markers": {},
"replication_key": "date_modified",
"replication_key_value": "2021-05-15T15:14:40"
}
}
}
}
However, I'm not sure how I can extract "replication_key_value" to pass into the params on a subsequent run.
Any help would be much appreciated and if anyone else is working on WooCommerce it would be good to chat 🙂
Best,
Jazzyaaronsteers
05/15/2021, 5:26 PMget_url_params()
.aaronsteers
05/15/2021, 5:26 PMget_starting_timestamp()
in this example: https://www.github.com/dataops-tk/tap-powerbi-metadata/tree/main/tap_powerbi_metadata%2Fstreams.pyjazzy
05/15/2021, 5:28 PMaaronsteers
05/15/2021, 5:30 PMjazzy
05/16/2021, 11:52 AM{
"bookmarks": {
"orders": {
"replication_key": "date_modified",
"replication_key_value": "2021-05-01T08:00:25"
}
}
}
It uses the replication_key_value correctly.
I think the issue was that running:
poetry run tap-woocommerce --config sample-config.json
Is basically running a fresh job each time so the final state message does not persist between runs. Therefore it was always using the date set in the config file.
This is the implementation logic based on the link you previously sent
if self.replication_key:
current_bookmark = self.get_starting_timestamp(partition)
if current_bookmark is None:
params["after"] = self.config.get("after")
else:
params["after"] = current_bookmark
The WooCommerce REST API only allows sorting on "date" and doesn't specify which date this actually is.
Therefore the Singer SDK only writes the state message once the job has completed as per:
https://gitlab.com/meltano/singer-sdk/-/blob/main/docs/implementation/state.md#dealing-with-unsorted-streams
If I print the output of self.get_starting_timestamp(partition) it always returns None.
Is my understanding correct?aaronsteers
05/17/2021, 3:42 PMpoetry run tap-woocommerce --config sample-config.json --state state.json
Where state.json
is the (final) state output from a prior run.aaronsteers
05/17/2021, 3:42 PMjazzy
05/17/2021, 3:48 PMpoetry run tap-woocommerce --config sample-config.json
If it should persist the state afterwards as it does end with a STATE message as expected. Or if running that command is the same as running it from fresh each time?
Does that make sense?aaronsteers
05/17/2021, 3:52 PMjazzy
05/17/2021, 3:55 PM