Skip to content

Member Activity Service

Vijay Hawoldar requested to merge vij-member-activity-service into master

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
  • modifies RecordLastUserActivity controller concern to publish the Users::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)

The relevant Member record will only be updated once per day.

Refs #461338

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

  1. Create a Group with a Project
  2. Find your Member record associating your user to the Group
      member = Member.last
  3. 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)
  4. Perform an action in the group or the project, e.g. viewing the project repo
  5. Check the last_activity_on timestamp to see if it updated and check the updated_at
      member.reload.last_activity_on
      member.updated_at
  6. 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.

Edited by Vijay Hawoldar

Merge request reports