- Fork this repo
- Make changes to the code in the forked repository
- Once ready, create a PR from the forked repository into this repository
This is a Python 3 project.
- Database: postgres database
- Other Packages: psycopg2 (refer to requirements.txt)
-
The input database has Employee and Punches. The SQL file has the DDLs to seed data. The SQL is catered to PostgreSQL syntax.
-
The goal is to combine punches.
-
For the input in the database, below is the expected output
-
Special case: If there is a different activity between 2 of the same for the same employee, combine them to the bigger activity if the
middle
activity duration is <= 5 minutes e.g.Input
Lucy Picking 12:25 PM 1:00 PM
Lucy Cleaning 1:00 PM 1:05 PM
Lucy Picking 1:05 PM 2:00 PM
Expected output: cleaning rolls up into Picking Lucy Picking 12:25 PM 2:00 PM
****** EXPECTED OUTPUT BELOW ******
OUTPUT:
ID Name Activity Start Time End Time
Joe Picking 2021-01-24 9:05 AM 2021-01-24 10:00 AM
William Packing 2021-01-24 9:15 AM 2021-01-24 10:00 AM
Joe Packing 2021-01-24 11:00 AM 2021-01-24 11:45 AM
Joe Picking 2021-01-24 11:50 AM 2021-01-24 12:30 PM
Lucy Packing 2021-01-24 11:30 AM 2021-01-24 12:20 PM
William Packing 2021-01-24 10:30 AM 2021-01-24 3:00 PM
Lucy Picking 2021-01-24 12:25 PM 2021-01-24 2:00 PM
William Picking 2021-01-24 3:05 PM 2021-01-24 5:00 PM
Joe Cleaning 2021-01-24 11:55 PM 2021-01-25 12:35 AM