Open agritheory opened 5 months ago
I have faced similar issue previously when a client wanted to display Job card list with timer that shows time taken for an item in a machine, The issue I faced may be relevant to this as well as other projects.
So, The device was a monitor hanging from the roof above each manufacturing machine showcasing timer. Each monitor was using some or the other user's login to show the timer. The issue was: the timer was running on the JS(or headless app), it was not shared between the sessions or devices, that means if the timer started for JC 1
for Machine 1
the other monitor would still show JC 1
in queue for Machine 2
. This caused a little chaos on the floor on first release. The final solution to this was to make a async post request to server that store the current timestamp as start_time
and we used that flied as flag to indicate JC is in process or not, if it exists we use that to calculate difference between Now
and start_time
and resume the timer from the difference
on the JS(or headless app) that allowed us to have a share timer for each monitor. There can be a scenario where user may not want to store the start time in the database, in such case we can use frappe.cache
.
Timer Abstraction
We should expect this to interface with Job Card, Employee Checkin, Timesheets (vanilla and T&E implementations) and Tasks.