Use lock_key for BulkRefreshUserAssignmentsWorker

What does this MR do and why?

This MR refactors the code by extracting lock_key logic to add_on_purchase models itself, and uses it for both seat assignments refresh worker:

  1. RefreshUsersAssignmentsWorker
  2. BulkRefreshUserAssignmentWorker

This will ensure that only one refreshment Worker is run in the situation where a cron job is scheduled and on the same time the add_on_purchase was updated.

References

Related to #463817+

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

There is no change in logic, but simple refactor to extract and use lock_key. A Green CI build should suffice.

Edited by Bishwa Hang Rai

Merge request reports

Loading