Check user activity

I’m looking to build and interface that shows every user’s ‘last time active’ as we continue to work from home.

My initial thought was to loop through every artists and get their last recorded Event Log. Which works out perfect. However when you have over 100 people that i have to loop through before populating the interface, that is a lot of calls to shotgun.

Call 1: Get all human users in shotgun
Call 2: loop through every user and get their last known activity log entry.
Display in a list view every users name, and time elapsed since last user activity entry per user.

Is there a way to improve this or tackle this situation?



How about 1 call…
Get all logs in the last 24 hrs?
Parse the data from there…

I’ll get my coat :slight_smile:


May I suggest something like this?

        ['created_at', 'in_last', 2, 'WEEK'],
        ['user', 'type_is', 'HumanUser']
    summary_fields=[{'field':'created_at', 'type':'latest'}],
    grouping=[{'field': 'user', 'type': 'exact', 'direction': 'asc'}]

I’ve written this in Python, but it should apply to the REST API as well. I’ve restricted it to the last two weeks of EventLogEntries for performance reasons, and this could probably be restricted even more. The query will get you the last activity date for any user that has activity in the analyzed time window.

Querying EventLogEntries can be quite a resource-intensive task, so you should be very careful.

I should also add that querying EventLogEntries is somewhat inaccurate. Shotgun doesn’t log a fair amount of a user’s read-only activity. Additionally, if a user’s session never expires because they consistently log in before expiry, you won’t have any login events. All this to say, even if this method could be an approximation, we don’t currently have a reliable way to derive the information you seek.

Here is the documentation for the summarize() method in the Python API and the REST API.


Oh wow this is great stuff! I think summarize will help me out perfectly in what im trying to do. Thank you

1 Like

that’s not a bad idea either. I like this

1 Like