Reduce queries in service spec
What does this MR do?
Reduce queries in service spec. Total number of queries saved: 1609
Before
$ EVENT_PROF='sql.active_record' rspec spec/models/service_spec.rb
Total time: 00:04.527 of 00:10.400 (43.53%)
Total events: 4254
$ FPROF=1 rspec spec/models/service_spec.rb
[TEST PROF INFO] Factories usage
Total: 147
Total top-level: 68
Total time: 7.7580s
Total uniq factories: 10
total top-level total time time per call top-level time name
50 6 1.9744s 0.0395s 0.2189s namespace
44 28 6.5931s 0.1498s 4.1793s project
19 19 2.0361s 0.1072s 2.0361s jira_service
18 1 0.3002s 0.0167s 0.0037s jira_tracker_data
9 9 0.8958s 0.0995s 0.8958s service
2 2 0.3427s 0.1714s 0.3427s redmine_service
2 0 0.0528s 0.0264s 0.0000s issue_tracker_data
1 1 0.0122s 0.0122s 0.0122s slack_service
1 1 0.0558s 0.0558s 0.0558s group
1 1 0.0135s 0.0135s 0.0135s license
After
$ EVENT_PROF='sql.active_record' rspec spec/models/service_spec.rb
Total time: 00:02.902 of 00:07.057 (41.13%)
Total events: 2645
$ FPROF=1 rspec spec/models/service_spec.rb
[TEST PROF INFO] Factories usage
Total: 96
Total top-level: 41
Total time: 4.1879s
Total uniq factories: 11
total top-level total time time per call top-level time name
23 4 0.7469s 0.0325s 0.1139s namespace
19 3 3.1292s 0.1647s 0.6156s project
19 19 2.1044s 0.1108s 2.1044s jira_service
18 1 0.3198s 0.0178s 0.0048s jira_tracker_data
9 9 0.8903s 0.0989s 0.8903s service
2 2 0.3802s 0.1901s 0.3802s redmine_service
2 0 0.0550s 0.0275s 0.0000s issue_tracker_data
1 1 0.0117s 0.0117s 0.0117s slack_service
1 1 0.0518s 0.0518s 0.0518s group
1 0 0.0341s 0.0341s 0.0000s user
1 1 0.0152s 0.0152s 0.0152s license