Do not create project factories in view specs
What does this MR do and why?
Do not create project factories when not needed.
We're in a view spec, so we don't need to persist objects in the database. We instead build stubbed versions of those objects.
Impact
This change saved 1min spent on factories alone (from 1min20s locally to 19s
Before
[TEST PROF INFO] Time spent in factories: 01:20.049 (68.38% of total time)
[TEST PROF INFO] Factories usage
Total: 830
Total top-level: 260
Total time: 01:20.049 (out of 02:05.420)
Total uniq factories: 9
total top-level total time time per call top-level time name
252 0 15.9711s 0.0634s 0.0000s namespace
252 0 1.5903s 0.0063s 0.0000s organization
186 120 73.1151s 0.3931s 59.0142s project
66 66 5.8550s 0.0887s 5.8550s elasticsearch_indexed_namespace
66 66 14.4340s 0.2187s 14.4340s elasticsearch_indexed_project
3 3 0.0122s 0.0041s 0.0122s elastic_reindexing_subtask
3 3 0.0129s 0.0043s 0.0129s elastic_reindexing_task
1 1 0.7072s 0.7072s 0.7072s admin
1 1 0.0139s 0.0139s 0.0139s license
After
[TEST PROF INFO] Time spent in factories: 00:19.506 (52.41% of total time)
[TEST PROF INFO] Factories usage
Total: 470
Total top-level: 140
Total time: 00:19.506 (out of 00:44.755)
Total uniq factories: 9
total top-level total time time per call top-level time name
132 0 8.5067s 0.0644s 0.0000s namespace
132 0 0.8344s 0.0063s 0.0000s organization
66 0 14.0472s 0.2128s 0.0000s project
66 66 4.6442s 0.0704s 4.6442s elasticsearch_indexed_namespace
66 66 14.3616s 0.2176s 14.3616s elasticsearch_indexed_project
3 3 0.0176s 0.0059s 0.0176s elastic_reindexing_task
3 3 0.0131s 0.0044s 0.0131s elastic_reindexing_subtask
1 1 0.4574s 0.4574s 0.4574s admin
1 1 0.0128s 0.0128s 0.0128s license
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
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.