summaryrefslogtreecommitdiff
path: root/app/models
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'sh-optimize-discussion-json' into 'master'Yorick Peterse2017-09-181-1/+1
|\ | | | | | | | | | | | | Eliminate N+1 queries in loading discussions.json endpoint Closes #37955 See merge request gitlab-org/gitlab-ce!14327
| * Eliminate N+1 queries in loading discussions.json endpointsh-optimize-discussion-jsonStan Hu2017-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In #37955,we see that the profile had a number of N+1 queries from repeated access to `cross_reference_not_visible_for?`. This was optimized in previous versions of GitLab by rendering all notes at once, counting the number of visible references, and then using that number to check whether a system note should be fully redacted. There was also another N+1 query calling `ProjectTeam#member?`, which did not take advantage of an optimization in prepare_notes_for_rendering that would preload the maximum access level per project. Closes #37955
* | Merge branch '37789-followup-for-read-registry-change' into 'master'Rémy Coutable2017-09-181-1/+1
|\ \ | | | | | | | | | | | | | | | | | | Clean up read_registry scope changes Closes #37789 See merge request gitlab-org/gitlab-ce!14307
| * | Clean up read_registry scope changesRobin Bobbitt2017-09-181-1/+1
| | | | | | | | | | | | Closes #37789
* | | Merge branch 'operation-service-merge' into 'master'Rémy Coutable2017-09-181-37/+20
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | Prepare Repository#merge for migration to Gitaly Closes gitaly#559 See merge request gitlab-org/gitlab-ce!14154
| * | Prepare Repository#merge for migration to Gitalyoperation-service-mergeJacob Vosmaer2017-09-151-37/+20
| | |
* | | Merge branch 'master' into 'issue_37640'issue_37640Felipe Artur2017-09-1528-58/+93
|\ \ \ | | | | | | | | | | | | # Conflicts: # db/schema.rb
| * \ \ Merge branch 'fix-share-with-group-lock-update' into 'master'Robert Speicher2017-09-151-1/+8
| |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix setting share_with_group_lock Closes #37916 See merge request gitlab-org/gitlab-ce!14300
| | * | | Fix setting share_with_group_lockfix-share-with-group-lock-updateYorick Peterse2017-09-151-1/+8
| | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit running Namespace#force_share_with_group_lock_on_descendants would result in updating _all_ namespaces in the namespaces table, not just the descendants. This is the result of ActiveRecord::Relation#update_all not taking into account the CTE. To work around this we use the CTE query as a sub-query instead of directly calling #update_all. To prevent this from happening the relations returned by Gitlab::GroupHierarchy are now marked as read-only, resulting in an error being raised when methods such as #update_all are used. Fortunately on GitLab.com our statement timeouts appear to have prevented this query from actually doing any damage other than causing a very large amount of dead tuples. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/37916
| * | | created services for keyshaseeb2017-09-153-16/+0
| | | |
| * | | Merge branch 'projects-controller-show' into 'master'Rémy Coutable2017-09-152-0/+21
| |\ \ \ | | |/ / | |/| | | | | | | | | | SQL performance improvements for ProjectsController#show See merge request gitlab-org/gitlab-ce!14226
| | * | Memoize the latest builds of a pipelineprojects-controller-showYorick Peterse2017-09-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This ensures that if a pipeline is present for the last commit on a project's homepage we only run 1 query to get the builds, instead of running 2 queries. See https://gitlab.com/gitlab-org/gitlab-ce/issues/36878#note_40073339 for more information.
| | * | Memoize pipelines for project download buttonsYorick Peterse2017-09-141-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds Project#latest_successful_pipeline_for and Project#latest_successful_pipeline_for_default_branch. The 2nd method memoizes the result (taking nil values into account) to ensure the underlying query isn't executed multiple times when viewing a project's homepage. See https://gitlab.com/gitlab-org/gitlab-ce/issues/36878#note_40073607 for more information.
| * | | Merge branch 'ci-environment-status-performance' into 'master'Stan Hu2017-09-141-1/+4
| |\ \ \ | | |_|/ | |/| | | | | | | | | | | | | | | | | | Constrain environment deployments to project IDs Closes #36877 See merge request gitlab-org/gitlab-ce!14252
| | * | Constrain environment deployments to project IDsYorick Peterse2017-09-131-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When querying the deployments of an environment the query Rails produces will be along the lines of the following: SELECT * FROM deployments WHERE environment_id = X For queries such as this (or queries that use this as their base and add more conditions) there is no meaningful index that can be used as long as deployments.project_id is not part of a WHERE clause. To work around this we change that "has_many :deployments" relation to always add a "WHERE project_id = X" condition. This means that queries filtering deployments can make better use of the existing indexes. For example, when filtering by deployments.iid this will result in the following query: SELECT * FROM deployments WHERE environment_id = X AND project_id = Y AND iid = Z This means PostgreSQL can use the existing index on (project_id, environment_id, iid) instead of having to use a different index (or none at all) and having to scan over a large amount of data. Query plan wise this means that instead of this query and plan: EXPLAIN (BUFFERS, ANALYZE) SELECT deployments.* FROM deployments WHERE deployments.environment_id = 5 AND deployments.iid = 225; Index Scan using index_deployments_on_project_id_and_iid on deployments (cost=0.42..14465.75 rows=1 width=117) (actual time=6.394..38.048 rows=1 loops=1) Index Cond: (iid = 225) Filter: (environment_id = 5) Rows Removed by Filter: 839 Buffers: shared hit=4534 Planning time: 0.076 ms Execution time: 38.073 ms We produce the following query and plan: EXPLAIN (BUFFERS, ANALYZE) SELECT deployments.* FROM deployments WHERE deployments.environment_id = 5 AND deployments.iid = 225 AND deployments.project_id = 1292351; Index Scan using index_deployments_on_project_id_and_iid on deployments (cost=0.42..4.45 rows=1 width=117) (actual time=0.018..0.018 rows=1 loops=1) Index Cond: ((project_id = 1292351) AND (iid = 225)) Filter: (environment_id = 5) Buffers: shared hit=4 Planning time: 0.088 ms Execution time: 0.039 ms On GitLab.com these changes result in a (roughly) 11x improvement in SQL timings for the CI environment status endpoint. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36877
| * | | Merge branch 'gitlab-git-user' into 'master'Rémy Coutable2017-09-141-4/+4
| |\ \ \ | | | | | | | | | | | | | | | | | | | | Rename Gitlab::Git::Committer to User See merge request gitlab-org/gitlab-ce!14254
| | * | | Rename Gitlab::Git::Committer to UserJacob Vosmaer2017-09-141-4/+4
| | | | |
| * | | | Merge branch '37759-also-treat-newlines-as-separator' into 'master'Kamil Trzciński2017-09-141-1/+1
| |\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Treat newlines as separators for pipeline emails service Closes #37759 See merge request gitlab-org/gitlab-ce!14250
| | * | | | Also treat newlines as separator, as people would do thatLin Jen-Shin2017-09-131-1/+1
| | | |/ / | | |/| | | | | | | | | | | | | | | | | Before this fix, I don't know if those emails would work having newlines in them.
| * | | | Restore has_visible_content? to improve performance (cache)repo-cache-fixJarka Kadlecova2017-09-141-0/+6
| | |_|/ | |/| | | | | | | | | | This method was moved to ::Git but it is not cached there which causes performance problems
| * | | Merge branch '34510-board-issues-sql-speedup' into 'master'Douwe Maan2017-09-141-1/+6
| |\ \ \ | | |_|/ | |/| | | | | | | | | | | | | | | | | | fix #34510 add association preloading for issue boards Closes #34510 See merge request gitlab-org/gitlab-ce!14198
| | * | fix another N+1 query for label priorities34510-board-issues-sql-speedupmicael.bergeron2017-09-121-1/+6
| | | | | | | | | | | | | | | | added a QueryRecorder for IssuesController#index.json
| * | | Merge branch 'patch-26' into 'master'Rémy Coutable2017-09-131-3/+0
| |\ \ \ | | |_|/ | |/| | | | | | | | | | Delete duplicated lines. See merge request !14180
| | * | Delete duplicated lines.Shinichi Maeshima2017-09-111-3/+0
| | | |
| * | | Merge branch 'zj-usage-data-auto-devops' into 'master'Kamil Trzciński2017-09-131-0/+3
| |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add usage ping for Auto DevOps Closes #37648 See merge request !14162
| | * | | Add auto devops enabled/disabled to usage pingZeger-Jan van de Weg2017-09-121-0/+3
| | | | |
| * | | | Merge branch '5836-move-lib-ci-into-gitlab-namespace' into 'master'Grzegorz Bizon2017-09-1313-16/+16
| |\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolve "Move `lib/ci` to `lib/gitlab/ci`" Closes #5836 See merge request !14078
| | * | | | move `lib/ci/mask_secret.rb` into `lib/gitlab/ci/mask_secret.rb`Maxim Rydkin2017-09-121-2/+2
| | | | | |
| | * | | | move `lib/ci/gitlab_ci_yaml_processor.rb` into `lib/gitlab/ci/yaml_processor.rb`Maxim Rydkin2017-09-122-3/+3
| | | | | |
| | * | | | move `lib/ci/model.rb` into `lib/gitlab/ci/model.rb`Maxim Rydkin2017-09-1211-11/+11
| | | |_|/ | | |/| |
| * | | | Merge branch 'revert-2f46c3a8' into 'master'Robert Speicher2017-09-121-0/+1
| |\ \ \ \ | | |/ / / | |/| | | | | | | | | | | | | Revert "Merge branch 'revert-f2421b2b' into 'master'" See merge request !14190
| | * | | Revert "Merge branch 'revert-f2421b2b' into 'master'"revert-2f46c3a8Annabel Dunstone Gray2017-09-111-0/+1
| | | | | | | | | | | | | | | This reverts merge request !14148
| * | | | Decrease Perceived Complexity threshold to 15Maxim Rydkin2017-09-121-12/+20
| | | | |
| * | | | Merge branch 'housekeeping_settings' into 'master'Douwe Maan2017-09-121-2/+2
| |\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow to use same periods for housekeeping tasks Closes #34981 See merge request !13711
| | * | | | Allow to use same periods for housekeeping tasksAlex Lossent2017-09-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This enables skipping a lesser housekeeping task (incremental or full repack) by consistently scheduling a higher task (respectively full repack or gc) with the same period. Cf. #34981
| * | | | | Merge branch 'hide-read-registry-scope-when-registry-disabled' into 'master'Kamil Trzciński2017-09-121-1/+1
| |\ \ \ \ \ | | |_|/ / / | |/| | | | | | | | | | | | | | | | Hide read_registry scope when registry is disabled on instance See merge request !13314
| | * | | | Hide read_registry scope when registry is disabled on instanceRobin Bobbitt2017-08-211-1/+1
| | | | | |
* | | | | | Fix project feature being deleted when updating project with invalid ↵Felipe Artur2017-09-122-2/+4
|/ / / / / | | | | | | | | | | | | | | | visibility level
* | | | | Merge branch 'import-sources-fix' into 'master'Rémy Coutable2017-09-111-1/+1
|\ \ \ \ \ | |_|/ / / |/| | | | | | | | | | | | | | Read import sources from setting at first initialization See merge request !14141
| * | | | Read import sources from setting at first initializationVisay Keo2017-09-091-1/+1
| | |_|/ | |/| |
* | | | Merge branch 'user-recent-push' into 'master'Douwe Maan2017-09-113-14/+45
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework how recent push events are retrieved Closes #35990 See merge request !13995
| * | | | Rework how recent push events are retrieveduser-recent-pushYorick Peterse2017-09-083-14/+45
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Whenever you push to a branch GitLab will show a button to create a merge request (should one not exist already). The underlying code to display this data was quite inefficient. For example, it involved multiple slow queries just to figure out what the most recent push event was. This commit changes the way this data is retrieved so it's much faster. This is achieved by caching the ID of the last push event on every push, which is then retrieved when loading certain pages. Database queries are only executed if necessary and the cached data is removed automatically once a merge request has been created, or 2 hours after being stored. A trade-off of this approach is that we _only_ track the last event. Previously if you were to push to branch A and B then create a merge request for branch B we'd still show the widget for branch A. As of this commit this is no longer the case, instead we will only show the widget for the branch you pushed to most recently. Once a merge request exists the widget is no longer displayed. Alternative solutions are either too complex and/or too slow, hence the decision was made to settle for this trade-off. Performance Impact ------------------ In the best case scenario (= a user didn't push anything for more than 2 hours) we perform a single Redis GET per page. Should there be cached data we will run a single (and lightweight) SQL query to get the event data from the database. If a merge request already exists we will run an additional DEL to remove the cache key. The difference in response timings can vary a bit per project. On GitLab.com the 99th percentile of time spent in User#recent_push hovers between 100 milliseconds and 1 second, while the mean hovers around 50 milliseconds. With the changes in this MR the expected time spent in User#recent_push is expected to be reduced down to just a few milliseconds. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/35990
* | | | Merge branch 'feature/gpg-verification-status-remove-ignore-rule' into 'master'Douwe Maan2017-09-111-3/+0
|\ \ \ \ | |_|/ / |/| | | | | | | | | | | Remove ignore rule for GpgSignature#valid_signature See merge request !14050
| * | | Revert "make valid_signature an ignored column"Alexis Reigel2017-09-051-3/+0
| | | | | | | | | | | | | | | | This reverts commit cce9afa38a8aa3f3e5a43ab952e1c022c9dd9385.
* | | | Revert "Merge branch ↵revert-f2421b2bRubén Dávila2017-09-081-1/+0
| | | | | | | | | | | | | | | | | | | | '35012-navigation-add-option-to-change-navigation-color-palette' into 'master'" This reverts merge request !13619
* | | | Merge branch '29943-environment-folder' into 'security-9-5'Kamil Trzciński2017-09-071-7/+6
| |/ / |/| | | | | | | | | | | Do not use `location.pathname` when accessing environments folders See merge request !2147
* | | Merge branch 'improve-share-locking-feature-for-subgroups' into 'master'Douwe Maan2017-09-071-0/+14
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Improve "Share with group lock" feature for subgroups Closes #30550 See merge request !13944
| * | | Refactor based on code reviewMichael Kozono2017-09-061-2/+2
| | | |
| * | | Enable share_with_group_lock on subgroupMichael Kozono2017-09-061-0/+14
| | | | | | | | | | | | | | | | …when needed
* | | | Merge branch '37158-autodevops-banner' into 'master'Kamil Trzciński2017-09-071-0/+4
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolve "Banner to enable Auto DevOps at project level" Closes #37158 See merge request !13991