User activity time calculation

I have an insane problem that is pickling my brain at the moment.

I’m creating a learning app. When users click buttons within the app, a thing called ‘Log Entry’ is created for that user (just the basic fields so I can filter by User).

What I want is to be able to show how long they were active for, considering that anything more than 15 minutes of inactivity constitutes becoming inactive. If the user clicks something after this 15 minute period, I want that to be considered as the start of a new period of activity.

I want the app admins to be able to generate a table of active periods, for example:

Date: 19/03/18, Start active time: 11:00, End active time 14:30
Date: 20/03/18, Start active time: 12:30, End active time 13:05
etc.

The calculation of Start active time and End active time is a result of a Bubble search that finds the 12:30 entry because no other entries before it are less than 15 mins away. All the entries between 12:30 and 13:45 are less than 15 mins apart. The next entry after 13:05 is more than 15 mins away. Here’s what the database used for that calculation would look like:

Log Entries: filtered by UserX

20/03/18 11:15
20/03/18 12:30
20/03/18 12:40
20/03/18 12:54
20/03/18 13:05
20/03/18 16:30

Does that make any sense at all? I’m confusing myself even trying to explain it. I’d appreciate any help you guys can give.

Thanks, Richard.

1 Like