I have a project that's used by a factory for inputting figures into a table to print out throughout the day.
They're having an issue with multiple users attempting to edit the same data into these table at the same time and have requested a solution. They all have separate accounts and want to prevent another user from viewing a particular table if another user is already working on that particular table. Figures are put into the same table as the products progress through the production line so multiple users do need access to the same table, they just don't want it to be at the same time.
Are there any existing libraries that could help with this?
The idea I'm currently leaning towards is making an axios call every 30 seconds on the table entry page that will alter a flag in the database that says the user is currently online, then set them to offline if say 2 minutes goes by without a successful call. Would there be any potential issue with this. One I can currently picture is a situation where a user will forget to close the page when they're finished and block anyone from accessing that page, so I'd probably need to implement some form of activity monitor as well.
Any advice on approaches for this would be appreciated!
you could potentially use livewire and let multiple people use it at once. If you accept a new value, update the column that changed then re render the table, then there would only be a problem if two people changed the same column at the same time
Hi @Snapey, it would be the same columns they're editing.
The users get figures from another piece of software so if someone further up the production line see's a section that hasn't been populated they'll start to fill it in with their figures while someone further down could be filling it in at the same time with slightly altered figures if any alterations were required to that particular product.
Thanks @RayC,
I spoke to the client and we agreed to keep it simple. I've added a field when viewing specific records that logs the timestamp and user_id of the last person to access it. I then have a grace window of 3 minutes that will then unlock the page if there's been no further activity. I also have a timer set on the page that prevents the user from keeping the page on while unattended that will redirect them back to the main overview page if they're idle. Not a completely foolproof solution but they're happy enough with it without adding too many complexities.