Member Activity Service
What does this MR do and why?
In order for us to identify dormant members in a namespace hierarchy, this MR:
- adds a new EventStore event,
Users::ActivityEvent
- adds a new worker to subscribe to the event,
Users::RecordLastActivityWorker
- adds a new service,
Members::ActivityService
, that the worker uses to:- find the relevant
Member
record for the given user and namespace - update the found record's
last_activity_on
timestamp
- find the relevant
- modifies
RecordLastUserActivity
controller concern to publish theUsers::ActivityEvent
event
This will trigger the publishing of the event every time any GET
request is made in a controller using the RecordLastUserActivity
concern, if a project or group is available. The controllers this will impact currently consists of:
- Groups
- Projects
- Issues
- Merge Requests
- Epics
Additional tracking of git actions/API/etc will be handled separately (likely in !157644 (merged))
The relevant Member record will only be updated once per day.
Refs #461338 (closed)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
- Create a Group with a Project
- Find your Member record associating your user to the Group
member = Member.last
- Check the
last_activity_on
timestamp and update it to a date in the past:member.last_activity_on member.update(last_activity_on: 1.week.ago)
- Perform an action in the group or the project, e.g. viewing the project repo
- Check the
last_activity_on
timestamp to see if it updated and check theupdated_at
member.reload.last_activity_on member.updated_at
- Re-perform the same action, and there should be no change to the Member record's
updated_at
as we only track once per day:member.reload.updated_at # should be the same as above
You can optionally tail the sidekiq logs (log/sidekiq.log
) and view the activity event being processed by sidekiq.