Index work items when project visibility level changes

What does this MR do and why?

Found while working on !170853 (merged)

This MR has a few related changes in it:

  1. fixes a bug where project visibility changes are not updating the project's indexed work items for Advanced search.
  2. does not index namespace_visibility_level for project level work items. This field is not used to query project level work items (the project_level_visibility field is). Additionally, this field is not updated when the namespace visibility level is changed for project level work items. Group associations are updated by a worker which calls group.work_items in batches. Since project level work items are not associated with a group (they are associated with a project namespace), they do not get updated by the worker. I think it's ok to not fill this field out

Note: The indexed work item data may be out of sync with the database. I've opened a follow up MR to reindex all work items that will be merged after this one. I want to keep them separate so I can backport this fix, we usually do not backport migrations

References

Please include cross links to any resources that are relevant to this MR This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

!170853 (merged)

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.

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. Enable elasticseacch for gdk
  2. Create a few work items in a public project, I used project id 7 (they must be issues/work items, not epic work items)
  3. (query below) query elasticsearch directly to see the data, pay attention to the project_visibility_level field
  4. Update the project visibility level to private
  5. query elasticsearch directly to see the data, verify the project_visibility_level field was updated
curl --request POST \
  --url http://localhost:9200/gitlab-development-work_items/_search \
  --header 'Content-Type: application/json' \
  --data '{
	"size": 30,
	"query": {
		"term": {
			"project_id": 7
		}
	}
}'
Edited by Terri Chu

Merge request reports

Loading