Adds API support for Project Deployment Frequency
Related to Issues
- API support for Deployment Frequency: #279039 (closed)
What does this MR do?
Creates an API to access Deployment Frequency data at the Project level.
Does this MR meet the acceptance criteria?
Database
Migrations:
± bin/rake db:migrate:up VERSION=20201211042306
== 20201211042306 AddDeploymentsFinderByFinishedAtIndex: migrating ============
-- transaction_open?()
-> 0.0000s
-- index_exists?(:deployments, [:project_id, :finished_at], {:where=>"status = 2", :name=>"index_deployments_on_project_and_finished", :algorithm=>:concurrently})
-> 0.0097s
-- execute("SET statement_timeout TO 0")
-> 0.0001s
-- add_index(:deployments, [:project_id, :finished_at], {:where=>"status = 2", :name=>"index_deployments_on_project_and_finished", :algorithm=>:concurrently})
-> 0.0152s
-- execute("RESET ALL")
-> 0.0001s
== 20201211042306 AddDeploymentsFinderByFinishedAtIndex: migrated (0.0257s) ===
± bin/rake db:migrate:down VERSION=20201211042306
== 20201211042306 AddDeploymentsFinderByFinishedAtIndex: reverting ============
-- transaction_open?()
-> 0.0000s
-- index_exists?(:deployments, [:project_id, :finished_at], {:where=>"status = 2", :name=>"index_deployments_on_project_and_finished", :algorithm=>:concurrently})
-> 0.0074s
-- execute("SET statement_timeout TO 0")
-> 0.0001s
-- remove_index(:deployments, {:where=>"status = 2", :name=>"index_deployments_on_project_and_finished", :algorithm=>:concurrently, :column=>[:project_id, :finished_at]})
-> 0.0104s
-- execute("RESET ALL")
-> 0.0001s
== 20201211042306 AddDeploymentsFinderByFinishedAtIndex: reverted (0.0185s) ===
Queries:
SELECT
"deployments".*
FROM
"deployments"
INNER JOIN "environments" ON "environments"."id" = "deployments"."environment_id"
WHERE
"deployments"."project_id" = :project_id
AND (deployments.created_at >= :start_datetime)
AND (deployments.created_at < :end_datetime)
AND "deployments"."status" = 2
AND "environments"."name" = :environment_name;
Plan with execution:
Nested Loop (cost=1.00..55847.19 rows=918 width=139) (actual time=1.445..1111.047 rows=36331 loops=1)
Buffers: shared hit=662633 read=24746
I/O Timings: read=642.676
-> Index Scan using index_deployments_on_project_and_finished on public.deployments (cost=0.57..18593.04 rows=14577 width=139) (actual time=0.390..774.724 rows=140998 loops=1)
Index Cond: ((deployments.project_id = 7764) AND (deployments.finished_at >= (now() - '30 days'::interval)) AND (deployments.finished_at < now()))
Buffers: shared hit=96424 read=24745
I/O Timings: read=641.462
-> Index Scan using environments_pkey on public.environments (cost=0.43..2.56 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=140998)
Index Cond: (environments.id = deployments.environment_id)
Filter: ((environments.name)::text = 'production'::text)
Rows Removed by Filter: 1
Buffers: shared hit=566209 read=1
I/O Timings: read=1.214
Recommendations:
❗ Query processes too much data to return a relatively small number of rows. – Reduce data cardinality as early as possible during the execution, using one or several of the following techniques: new indexes, partitioning, query rewriting, denormalization. See the visualization of the plan to understand which plan nodes are the main bottlenecks. Show details
❗ Add LIMIT – The number of rows in the result set is too big. Limit number of rows. Show details
❗ Specialized index needed – The index(es) currently used does not serve quite well for the needs of this query (notice Rows Removed by Filter: ..., meaning that the index fetched many non-target rows). Consider adding more specialized index(es). Show details
Summary:
Time: 1.115 s
- planning: 0.906 ms
- execution: 1.114 s
- I/O read: 642.676 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 662633 (~5.10 GiB) from the buffer pool
- reads: 24746 (~193.30 MiB) from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
Permalink: https://postgres.ai/console/gitlab/gitlab-production-tunnel/sessions/1515/commands/5068. (edited)
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Merge request reports
Activity
changed milestone to %13.7
1 Warning ⚠ This merge request is quite big (more than 617 lines changed), please consider splitting it into multiple merge requests. 1 Message 📖 This merge request adds or changes documentation files. A review from the Technical Writing team before you merge is recommended. Reviews can happen after you merge. Documentation review
The following files require a review from a technical writer:
doc/api/project_analytics.md
doc/user/project/index.md
The review does not need to block merging this merge request. See the:
- Technical Writers assignments for the appropriate technical writer for this review.
- Documentation workflows for information on when to assign a merge request for review.
Reviewer roulette
Changes that require review have been detected! A merge request is normally reviewed by both a reviewer and a maintainer in its primary category (e.g. frontend or backend), and by a maintainer in all other categories.
To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited, or the chosen person is unavailable.
To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.
Once you've decided who will review this merge request, mention them as you normally would! Danger does not automatically notify them for you.
Category Reviewer Maintainer backend Vijay Hawoldar ( @vij
) (UTC+0, 8 hours ahead of@atroschinetz
)Shinya Maeda ( @shinya.maeda
) (UTC+7, 15 hours ahead of@atroschinetz
)database Maxime Orefice ( @morefice
) (UTC-5, 3 hours ahead of@atroschinetz
)Adam Hegyi ( @ahegyi
) (UTC+1, 9 hours ahead of@atroschinetz
)If needed, you can retry the
danger-review
job that generated this comment.Generated by
🚫 DangerEdited by 🤖 GitLab Bot 🤖removed workflowin dev label
mentioned in issue #279039 (closed)
- Resolved by Amy Troschinetz
added 216 commits
-
3c008d61...183746af - 215 commits from branch
master
- 329b8004 - Add API support for deployment frequency
-
3c008d61...183746af - 215 commits from branch
- Resolved by Amy Troschinetz
@sabrams How do I figure out how to actually test this locally? It's really not clear to me how URLs get constructed here. Something like this?
curl -sXGET \ --url http://192.168.1.118:3000/api/v4/projects/9/ [???????] \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'private-token: OMIT'
It's not clear to me at all how I would figure out what the url would be from the
ee/lib/api/analytics/project_cycle_analytics.rb
file I've created here.
marked the checklist item Code review guidelines as completed
marked the checklist item Merge request performance guidelines as completed
marked the checklist item Style guides as completed
marked the checklist item Database guides as completed
marked the checklist item Separation of EE specific content as completed
added 753 commits
-
e9e0eaae...1fc08964 - 752 commits from branch
master
- c862888f - Add API support for deployment frequency
-
e9e0eaae...1fc08964 - 752 commits from branch
added databasereview pending label
added database label
- Resolved by Amy Troschinetz
added documentation label
added 2186 commits
-
2b80ea39...a3083266 - 2185 commits from branch
master
- 533098ee - Add API support for deployment frequency
-
2b80ea39...a3083266 - 2185 commits from branch
marked the checklist item Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. as completed
3 require 'spec_helper' 4 5 RSpec.describe API::Analytics::ProjectDeploymentFrequency do 6 let_it_be(:group) { create(:group, :private) } 7 let_it_be(:project) { create(:project, namespace: group) } 8 let(:current_user) { reporter } 9 10 let_it_be(:reporter) do 11 create(:user).tap { |u| project.add_reporter(u) } 12 end 13 14 let_it_be(:anonymous_user) { create(:user) } 15 16 shared_examples 'GET deployment_frequency' do |interval, from, to| 17 let(:feature_available) { true } 18 let(:params) { { project_path: project.full_path } } changed this line in version 19 of the diff
- Resolved by Amy Troschinetz
- Resolved by Amy Troschinetz
- Resolved by Amy Troschinetz
- Resolved by Amy Troschinetz