Topics: add `non_private_projects_count` counter
What does this MR do and why?
This MR is the first step of the issue Explore topics: improve counter consistency (#351115):
- adds the new
non_private_projects_countcolumn (and index) to theTopicmodel - adds a background migration to populate the
non_private_projects_countcounter - adds logic to update the
non_private_projects_countcounter if a project is saved
The counter is not used yet anywhere. This will happen in a next step of #351115.
/cc @bufferoverflow
Migrations
db:check-migrations job: https://gitlab.com/gitlab-org/gitlab/-/jobs/2022614075
How to set up and validate locally
- Create a private project
project1. - Visit the project settings and add the topic
topic1. - Check counter in Rails console:
Projects::Topic.find_by(name: 'topic1').non_private_projects_count➡ should be0 - Visit the project settings and change visibility to
public - Check counter in Rails console:
Projects::Topic.find_by(name: 'topic1').non_private_projects_count➡ should be1 - Visit the project settings and change visibility to
private - Check counter in Rails console:
Projects::Topic.find_by(name: 'topic1').non_private_projects_count➡ should be0 - Experiment with adding/removing topics on different project visibility levels.
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.
Edited by Peter Leitzen