-
-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/api/timesheets response (TimesheetCollection) missing modified timestamp #4902
Comments
I don't understand that. Can you explain further? The |
Here is a story.
In step 4, which
Also, sorry, one more requirement. The I do understand that it is a design decision that Kimai will use SQL (* A caveat, there IS an impractical way to maintain a local copy of all Kimai is to 1) wipe your local database, 2) repull ALL data from Kimai API, 3) do this every time you synchronize, like every 5 minutes.) |
Please don't sync "everything" all 5 minutes, otherwise I have to add stricter rate limits on the API 😁 Here is a script that might be interesting for your sync: https://github.com/kimai/api-sync You don't have to know which time the server thinks it is, you query relatively to your current time. The server uses UTC by the way to store the modified timestamp. |
Thank you, I will study that implementation. I consider that a workaround. For example, I will need to re-insert all records from the past hour, which is unnecessary database churn. And also it will break if my or the API server are ever more than an hour off the time sync (which might happen at daylight savings time). |
Describe the problem
Executive summary
The current API spec does not allow you to properly do incremental data loads.
(I only care about the timesheets resource. But this concept may in fact apply to other resources as well.)
Details
How you query
In the /api/timesheets route, you can query incremental records since your last query using:
Excerpt from Swagger docs: (sorry I don't have a canonical link for this, but I access at https://pacific.kimai.cloud/api/doc.json)
What you get
However the records returned are:
The problem
The request query "Only records changed after this date will be included" does not align with any data available in the response. Therefore it is not possible using available information to perform this common scenario:
Describe the solution you'd like
Update the response to include a
modified
timestamp:"TimesheetCollection": { "required": [ ... + "modified" ], ... }
And then in the /api/timesheets route, update specification to clearly say:
Describe alternatives you've considered
Wait for webhooks to be implemented.
But even this is insufficient. Because a proper sync will just wait for the webhook and then do the same sync process above. (This approach provides resiliency against failed/dropped webhooks.)
Screenshots
No response
Additional notes about deleting records
Performing a proper incremental data synchronization requires finding all modified (and deleted) records since the last load.
When data is deleted from the source system (Kimai) the best practice is:
deleted = true
modified
timeThen the API will see those records as being newly deleted since the last sync.
If Kimai does not act this way, it would be an additional blocker for doing proper incremental data sync.
GDPR note: if there is a desire to actually delete information from the system, here is how to do it. Update the
modified
column to NOW(), keep theid
column, and remove/reset all other information in that row. Never use SQL DELETE. In fact, the application shouldn't even have SQL DELETE permission.The text was updated successfully, but these errors were encountered: