fix(Clockify Node): Partial clockify trigger fix plus workaround #10803
+14
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes some aspects of the "new time entry" clockify trigger, as well as adding support for periodically fetching all entries for entry updating workaround.
Problem: This issue stems from a fundamental problem within the Clockify API, which does not allow access to most recent time entry submissions by date submitted (or finalized/created or stopped). Furthermore, Clockify only allows one to retrieve entries through start date (registered by the user) and end date (also inputted by the user) [plus a bit more irrelevant options]. The prior code seemed to have been treating the "start date" as submission/stop/finalization date (that's at least what it looks like, not sure if it was intentional), which caused problems such as discarding entries that have start dates prior to the latest checked date (so if it checked a minute ago, it would only fetch items from the current minute, then move onto the next minute).
Solution: Only set the "last checked"/"lastTimeChecked" variable when data is retrieved, then update the "lastTimeChecked" to the current time to skip already processed data. However, this doesn't update or account for modifications and/or additions after the "last checked" time is updated. This is why the new feature for polling all events is added, to support updating previous records, etc, though costly (meant to be used along with the fixed "new time entry" trigger, except at a slower interval).
Purpose: To put into place a system that gives a real time "feel" to clockify API updates while not requiring the use of webhooks and port forwarding. (this is useful for home servers)
Illustrations:
note: I use task and time entry interchangeably here
Previous method
New method
Update/manual insert workaround
Related Linear tickets, Github issues, and Community forum posts
Community post
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported) N/A