Skip to content

Update total count of runners for each type

Miguel Rincon requested to merge 345710-update-counters-runner--tabs into master

What does this MR do and why?

Depends on !77578 (merged) for backend

Runners are segregated by tabs in the admin UI. This change updates the view so that the total count of runners in each tab gets updated every time the user changes the search filters.

Changelog: changed

Screenshots or screen recordings

When each filter is applied, the tabs counters are updated 🎉

2022-01-07_14.58.19

How to set up and validate locally

  1. With some runners registered and logged in as admin
  2. Visit the runners admin http://gdk.test:3000/admin/runners
  3. Use the filters to search for a runner
  4. Confirm the tabs count (e.g. All 99) are updated as filters are applied

Database queries

The GraphQL count query generates the following database queries:

   (0.4ms)  SELECT COUNT(*) FROM "ci_runners" /*application:web,correlation_id:01FRT6DFAHNXXPZT4G0WAHH76Z,endpoint_id:graphql:getRunnersCount,db_config_name:main,line:/app/graphql/types/countable_connection_type.rb:20:in `count'*/
  ↳ app/graphql/types/countable_connection_type.rb:20:in `count'
   (0.4ms)  SELECT COUNT(*) FROM "ci_runners" WHERE "ci_runners"."runner_type" = 1 /*application:web,correlation_id:01FRT6DFAHNXXPZT4G0WAHH76Z,endpoint_id:graphql:getRunnersCount,db_config_name:main,line:/app/graphql/types/countable_connection_type.rb:20:in `count'*/
  ↳ app/graphql/types/countable_connection_type.rb:20:in `count'
   (0.4ms)  SELECT COUNT(*) FROM "ci_runners" WHERE "ci_runners"."runner_type" = 2 /*application:web,correlation_id:01FRT6DFAHNXXPZT4G0WAHH76Z,endpoint_id:graphql:getRunnersCount,db_config_name:main,line:/app/graphql/types/countable_connection_type.rb:20:in `count'*/
  ↳ app/graphql/types/countable_connection_type.rb:20:in `count'
   (0.3ms)  SELECT COUNT(*) FROM "ci_runners" WHERE "ci_runners"."runner_type" = 3 /*application:web,correlation_id:01FRT6DFAHNXXPZT4G0WAHH76Z,endpoint_id:graphql:getRunnersCount,db_config_name:main,line:/app/graphql/types/countable_connection_type.rb:20:in `count'*/

The same queries were already being executed in the admin_runners_data_attributes method which is being replaced, so the only thing that is changing is that the queries will now re-run whenever the filter changes (since the counts will now be contextual).

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #345710 (closed)

Edited by Miguel Rincon

Merge request reports