Our goal is to create a time frame in which the time periods when the user was online will be indicated. (In fact, it doesnβt matter which user we are talking about and where he was online). To get information about onliners, we can call the API method, someservice.com/api/?call=whoIsOnline
The whoIsOnline method will provide us with a list of users who are currently online. But the method is not an API to get information about who is NOT online .
So, we must build our timelines using the information received from whoIsOnline. Of course, there will be a measurement error (we cannot track information in real time). Suppose we will call the whoIsOline method every 2 minutes (yes, we will run our script cron every 2 minutes).
For example, calling whoIsOnline at 08:00 will return
Peter_id Michal_id Andy_id
calling whoIsOnline at 08:02 will return
Michael_id Andy_id George_id
As you can see, Peter is disabled, but we have a new onliner - George.
Available tools are Db (MySQL) / text files / keystore (Redis / memcache) ; Feel free to choose any of them (or even all).
So, we should get such information
George_id was online... 12 May: 08:02-08:30, 12:40-12:46, 20:14-22:36 11 May: 09:10-12:30, 21:45-23:00 10 May: was not online
And now the question is ...
- How do you store information for such deadlines?
- How would you query / calculate information about time periods when a user was online?
Additional Information..
- You cannot update information about offline users, only users who are currently online.
- The solution should be flexible: timeline information can be provided for any time zone.
- We should only store information for the last 7 days.
- Each user seen online automatically receives their own identifier in our database.
Uff .. it was very difficult for me to write it because my English is very poor, but I hope that my question will be clear to you.
Thanks.