Add members activity tracker worker
What does this MR do and why?
This MR adds GitlabSubscriptions::Members::RecordLastActivityWorker It is used to subscribe to ::Users::ActivityEvent and record the user activity in relation to namespace membership.
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.
How to set up and validate locally
-
Run
gdk restart rails-background-jobs redis -
Setup the machine:
gdk rails c# enable feature flag ::Feature.enable(:track_member_activity) # true # clear existing records, if any GitlabSubscriptions::SeatAssignment.destroy_all -
Create a new root Group, with a Project
-
Perform an action in the group or the project, e.g. viewing the project repo
-
Check that
GitlabSubscriptions::SeatAssignmentrecord has been createdGitlabSubscriptions::SeatAssignment.all # should return new records created # Or, namespace = Group.last # group created user = User.find(ID) # ID: your user id seat_assignment = GitlabSubscriptions::SeatAssignment.find_by_namespace_and_user(namespace, user) # returns record to the new group -
Re-perform the same action, and there should be no change to the
seat_assignmentrecord'slast_activity_onas we only track once per day:seat_assignment.reload.last_activity_on # should be the same as above -
You can visit any other existing projects in your
local gdkand see theGitlabSubscriptions::SeatAssignmentrecords being created.
You can optionally tail the sidekiq logs and view the activity event being processed by sidekiq:
tail -F log/sidekiq.log | grep -F --line-buffered 'GitlabSubscriptions::Members::RecordLastActivityWorker'
Related to #461338 (closed)