Update last_assigned_users_refreshed_at column
What does this MR do and why?
This is a small follow up to also update the last_assigned_users_refreshed_at
column, when we refresh the assigned users via RefreshAssignmentWorker
.
This will help us with skipping the add_on_purchase
when refreshing via the CronJob BulkRefreshUserAssignmentsWorker, if the add_on_purchase
was already refreshed within the last 12 hours.
How to set up and validate locally
- Check out this branch
- Create a new root group namespace
- Setup some seed records
namespace = Namespace.last
add_on = GitlabSubscriptions::AddOn.find_or_create_by!(name: "code_suggestions") {|e| e.description = "Test"}
add_on_purchase = GitlabSubscriptions::AddOnPurchase.create!(
add_on: add_on, namespace: namespace, expires_on: 1.month.from_now, quantity: 5, purchase_xid: 'A-S0001'
)
# enable the feature flag
Feature.enable(:hamilton_seat_management)
add_on_purchase.reload.last_assigned_users_refreshed_at # nil
GitlabSubscriptions::AddOnPurchases::RefreshUserAssignmentsWorker.new.perform(namespace.id)
add_on_purchase.reload.last_assigned_users_refreshed_at # not nil
SQL
UPDATE "subscription_add_on_purchases" SET "last_assigned_users_refreshed_at" = '2023-10-16 08:39:35.261337' WHERE "subscription_add_on_purchases"."id" = 1014120
Postgres AI: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/23182/commands/74631
Previous MR reference with same query: !132419 (merged)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #428290 and #424758
Edited by Bishwa Hang Rai