I am having a hard time trying to figure out the best way to report on and calculate layered time data.
The problem:
A person can sign in multiple times, during this sign in there are multiple statuses a person can be a part of. These statuses can be different per sign in per person. I am trying to figure out the best way to calculate time spent in each status as one whole session flattened together.
Let L1
be login 1 for person 1, let L2
be login 2. Essentially I am trying to calculate B
or Billable
status.
Assuming they were only ever in a Billable
status on both logins then the bottom line would be the time spent in Billable
.
Current solution
We store a session in our Postgres database and every 30 minutes go back and flatten the sessions into one based on start/end time and figure out time in each status. This works great for reporting that is based at least 30 minutes back, but not for real time reporting.
My tools:
I am trying to save each flattened second in each status per person to a Cassandra table. What would such a table look like? Could doing these calculations be a purely database operation?
Anyone got any ideas on how to flatten this data in C* so we only get the seconds each person has spent in each status regardless of how many logins were reporting that status?