Follow-up from "Populate dedicated hosted runner compute minute usage"

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

The following discussions from !180449 (merged) should be addressed:

I'm thinking as a follow-up improvement we could update all places to do some sql to do this like:

INSERT INTO hosted_runner_usages
  (runner_id, billing_month, root_namespace_id, project_id, compute_minutes_used, updated_at)
VALUES
  (712, '2025-04-01', 1640, 850, 120, NOW())
ON CONFLICT (runner_id, billing_month, root_namespace_id, project_id) 
DO UPDATE SET 
  compute_minutes_used = COALESCE(hosted_runner_usages.compute_minutes_used, 0) + <build_minutes>,
  updated_at = NOW();

Which combines a single query with the update_counters where we update the usage based on the current db value not the value in memory. However, it might not be worth the fewer queries and because it skips callbacks.

  • @panoskanell started a discussion:

    We can also wrap this with the spec/support/shared_examples/workers/idempotency_shared_examples.rb suite for better coverage.

  • @panoskanell started a discussion:

    This is a very useful class, I believe we should officially document this whenever we get the chance!

Edited by 🤖 GitLab Bot 🤖