DEV Community

Adekoyejo Akinhanmi
Adekoyejo Akinhanmi

Posted on • Updated on

Design for a time clocking app

I have been tasked with designing the server side application for a time clocking app. The application is supposed to keep track of when employees resume work each day and when they leave. The bottleneck I am experiencing is that the device for clocking in and clocking out is a fingerprint scanner and only one device is supposed to manage the two actions. For the sake of calculations and all, I intend to keep both data on their individual tables however I do not know how to. In one solution, I intend to create a single endpoint which when called will check if the employee has checked in for that day and then move the log to a different table or if I should keep the data on one table and just do my computations of clock in and clock out.

P.S. I do not also know if the device can be programmed with multiple endpoints.

Top comments (1)

Collapse
 
sir_wernich profile image
Wernich ️

this is right up my ally. :)

what reader are you using? is it a simple "put your finger and clock" reader or does it have some buttons that they maybe can press to allow the employees to select on/off?

what you will probably end up doing is keeping track of the employee's current state and toggling it and storing all the clockings in one table. in your employee table you can have something like "CurrentState", which will tell you if the employee is currently clocked on or off (i suck at naming, so feel free to use a better name than that).

when you query the device, you can sort all the clockings by employee number and then by time, so you can then process each individual clocking for that employee and save it in the DB with either 1 for "on" or 0 for "off". when you're done with processing the employee's clockings, you write that status to the employee table, then move on to the next employee.

the fun part is deciding whether you're always just going to toggle, or if you will manually set the employee to be "off" at the end of the day. then you need to figure out what the "end of the day" will be: if it's midnight, then that's cool, but if someone can possibly work past midnight, then you're going to have to start looking at setting up shifts and so on.

if you're not too interested in calculating the time that people work, then it gets easier, but you'll still want to put in a reasonable amount of logic to prevent the system from showing you clocked out at 8am and clocked in at 5pm. :)