Leonidas: Timesheets
The most mundane part of the day: Updating your time sheet
Timesheets, if you have to keep one, are one of the most frustrating things to keep up with. I understand some organizations do not keep time, some only keep enough time to know you were present for eight hours, then there are those that want to know what you accomplished in every 15-minute block of every day. That last one is pretty tough, but it opens the door to a ton of analysis and budget-keeping advantages.
In Leonidas, timesheets are fairly integral to the operation of everything else. Most employees only log in to Leonidas once a day (or week) to enter their time and then they leave. I set out to make sure it is the easiest component to use to lower any aggravation.
Data Retention
One thing to note right off the bat: I had to accommodate all the time entries from our previous time-keeping system, which came to life in late-2000. Querying on over twenty years of data is not exactly quick, but MariaDB supports table partitioning. Partitioning based on the time entry’s year, I could cut the query space down to a much more manageable chunk since 99% of all queries would be against “this” year or “last” year.
|
|
With this CREATE
statement, time entries are placed in their partition based on the year of their date and any query with a date in the WHERE
clause will automatically only span the appropriate partitions.
ISO-8601
When you think of timesheets, you think of a weekly record of the tasks and time spent. Representing “a week” actually took a bit of time to figure out until I stumbled upon the ISO-8601 week date format, which allowed me to represent a full week with just a small number (YYYYWW). This yearweek number is readily parsed by DateTime, available in SQL, easy on the URL when scrubbing between weeks, and manipulates easily.
Looking back, I could (should?) make the
time_entry_hours
table above only store the day of the week (1-7) and the yearweek intime_entries
would allow users to move their time entries between weeks. I don’t think I did this because I needed to query hours directly with date ranges instead of week ranges. Maybe it is an experiment I can carry out for academic purposes.
|
|
As the time_entries
table approaches a million records and time_entry_hours
approaches two-million, performance continues to stay consistent. This data integrates into budgeting components elsewhere in Leonidas, it helps the company determine employee workload, and even leads to calculating burn rates to determine if the company needs to hire new employees.