I have a system which calculates the work time of a user on a specific task. The main issue is that the tasks take a variable amount of time to complete. Some take a few hours and some take a few days or even a week.
Each task has a start and a stop time as well as pauses in between:
+------+---------------------+---------------------+
| _id | _start_date | _finish_date |
+------+---------------------+---------------------+
| 5013 | 2021-06-28 15:23:00 | 2021-06-29 09:25:01 |
| 5020 | 2021-06-28 15:33:00 | 2021-06-28 15:35:57 |
| 5025 | 2021-06-28 15:41:00 | 2021-07-06 07:33:24 |
+------+---------------------+---------------------+
Each task can have one, several or no pauses between the start and finish date:
+------+---------+---------------------+---------------------+
| _id | _job_id | _pause_start | _pause_end |
+------+---------+---------------------+---------------------+
| 1690 | 5013 | 2021-06-28 15:26:00 | 2021-06-29 09:24:48 |
| 1700 | 5025 | 2021-06-28 16:31:00 | 2021-06-29 10:52:56 |
| 1723 | 5025 | 2021-06-29 10:54:00 | 2021-07-06 07:32:59 |
+------+---------+---------------------+---------------------+
The main issue occurs when doing analytics. Lets say we have a project who has been worked on for 3 days long (20th to 22nd of July). If I generate a report for the 21st, I only want to get the repair time on the 21st which means that I'd have to calculate the time between the pauses for that day.
So I have come up with a solution - create a view which contains daily repair time of each task:
+---------+------------+--------------+
| _job_id | _date | _repair_time |
+---------+------------+--------------+
| 123 | 2022-07-20 | 25 |
| 123 | 2022-07-21 | 180 |
| 123 | 2022-07-22 | 45 |
+---------+------------+--------------+
So that when I run the report for the 20th or 21st or 22nd of July, I'd get the repair time for that day.
Is this possible to accomplish given my table structure?