grapevine
grapevine copied to clipboard
Track web client sessions for game admins
A simple report to see the number of opened web client sessions for a time range.
Report:
- Select from/to range, default to the last week
- Filter down to only sessions opened in that time period
- Display a table with the sessions and how long they were open
Ties with #70
This sounds interesting. Do you track things like this in ets? Anywhere to start reading for implementation hints?
The main admin section has a large part of what you'd need already. I'm tracking sessions in ecto already. So it'd be mostly copy pasting the admin stuff and adding in filters (since it's a straight list right now in the admin.) These are the important links for the admin section:
- https://github.com/oestrich/grapevine/tree/master/lib/web/templates/admin/client_session
- https://github.com/oestrich/grapevine/blob/master/lib/web/controllers/admin/client_session_controller.ex
And if you're curious how the tracking works:
- https://github.com/oestrich/grapevine/blob/master/lib/grapevine/statistics/server.ex
- https://github.com/oestrich/grapevine/blob/master/apps/telnet/lib/telnet/web_client.ex#L57
- https://github.com/oestrich/grapevine/blob/master/apps/telnet/lib/telnet/presence.ex#L103
When a session starts, it tells the presence server that it's online, which saves (via ets) that session's info. That also broadcasts a message to the main node (Statistics.Server
) which does the actual saving into ecto. It's a big convoluted but before I pulled out GrapevineData
the telnet node didn't have a nice way to using ecto things. I haven't gotten around to unwinding this to using the database directly.