summaryrefslogtreecommitdiff
path: root/app/models/issue.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use MergeRequestsClosingIssues cache data on Issue#closed_by_merge_requests ↵14192-issues-closed-by-merge-requests-using-metrics-dataPaco Guzman2016-10-201-1/+7
| | | | method
* Add self.project_foreign_key on both Issue and MergeRequestDouglas Barbosa Alexandre2016-10-191-0/+4
|
* Fix issue board related controllers to expose label priority per projectDouglas Barbosa Alexandre2016-10-191-0/+12
|
* Use the `IssuableBaseService` lifecycle hooks to cache ↵Timothy Andrew2016-09-211-1/+1
| | | | | | | `MergeRequestsClosingIssues` - Instead of overriding `create` and `update` in `MergeRequests::BaseService` - Get all merge request service specs passing
* Implement a second round of review comments from @DouweM.Timothy Andrew2016-09-211-1/+2
| | | | | | | | | | | | | | - Don't use `TableReferences` - using `.arel_table` is shorter! - Move some database-related code to `Gitlab::Database` - Remove the `MergeRequest#issues_closed` and `Issue#closed_by_merge_requests` associations. They were either shadowing or were too similar to existing methods. They are not being used anywhere, so it's better to remove them to reduce confusion. - Use Rails 3-style validations - Index for `MergeRequest::Metrics#first_deployed_to_production_at` - Only include `CycleAnalyticsHelpers::TestGeneration` for specs that need it. - Other minor refactorings.
* Implement (some) comments from @DouweM's review.Timothy Andrew2016-09-201-9/+0
| | | | | | - Move things common to `Issue` and `MergeRequest` into `Issuable` - Move more database-specific functions into `Gitlab::Database` - Indentation changes and other minor refactorings.
* Implement review comments from @yorickpeterseTimothy Andrew2016-09-201-3/+3
| | | | | | | | | | | | | | 1. Change multiple updates to a single `update_all` 2. Use cascading deletes 3. Extract an average function for the database median. 4. Move database median to `lib/gitlab/database` 5. Use `delete_all` instead of `destroy_all` 6. Minor refactoring
* Miscellaneous cycle-analytics-related changes.Timothy Andrew2016-09-201-5/+1
| | | | | | | | 1. Add indexes to `CreateMergeRequestsClosingIssues` columns. 2. Remove an extraneous `check_if_open` check that is redundant now. It would've been better to rebase this in, but that's not possible because more people are working on this branch.
* Remove extraneous code that was previously added for performance.Timothy Andrew2016-09-191-2/+2
|
* Improve performance of the cycle analytics page.Timothy Andrew2016-09-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. These changes bring down page load time for 100 issues from more than a minute to about 1.5 seconds. 2. This entire commit is composed of these types of performance enhancements: - Cache relevant data in `IssueMetrics` wherever possible. - Cache relevant data in `MergeRequestMetrics` wherever possible. - Preload metrics 3. Given these improvements, we now only need to make 4 SQL calls: - Load all issues - Load all merge requests - Load all metrics for the issues - Load all metrics for the merge requests 4. A list of all the data points that are now being pre-calculated: a. The first time an issue is mentioned in a commit - In `GitPushService`, find all issues mentioned by the given commit using `ReferenceExtractor`. Set the `first_mentioned_in_commit_at` flag for each of them. - There seems to be a (pre-existing) bug here - files (and therefore commits) created using the Web CI don't have cross-references created, and issues are not closed even when the commit title is "Fixes #xx". b. The first time a merge request is deployed to production When a `Deployment` is created, find all merge requests that were merged in before the deployment, and set the `first_deployed_to_production_at` flag for each of them. c. The start / end time for a merge request pipeline Hook into the `Pipeline` state machine. When the `status` moves to `running`, find the merge requests whose tip commit matches the pipeline, and record the `latest_build_started_at` time for each of them. When the `status` moves to `success`, record the `latest_build_finished_at` time. d. The merge requests that close an issue - This was a big cause of the performance problems we were having with Cycle Analytics. We need to use `ReferenceExtractor` to make this calculation, which is slow when we have to run it on a large number of merge requests. - When a merge request is created, updated, or refreshed, find the issues it closes, and create an instance of `MergeRequestsClosingIssues`, which acts as a join model between merge requests and issues. - If a `MergeRequestsClosingIssues` instance links a merge request and an issue, that issue closes that merge request. 5. The `Queries` module was changed into a class, so we can cache the results of `issues` and `merge_requests_closing_issues` across various cycle analytics stages. 6. The code added in this commit is untested. Tests will be added in the next commit.
* Add the "Review" cycle analytics section.Timothy Andrew2016-08-261-3/+7
|
* Add an `Issue::Metrics` model.Timothy Andrew2016-08-261-0/+9
| | | | | - And store the `first_associated_with_milestone_at` and `first_added_to_board_at` times, when an issue is saved.
* Further refactor and syntax fixes.Patricio Cano2016-08-151-2/+1
|
* Refactored AkismetHelper into AkismetService and cleaned up `Spammable`Patricio Cano2016-08-151-10/+3
| | | | - Refactored SpamCheckService into SpamService
* Refactored spam related code even furtherPatricio Cano2016-08-151-0/+13
| | | | | | | - Removed unnecessary column from `SpamLog` - Moved creation of SpamLogs out of its own service and into SpamCheckService - Simplified code in SpamCheckService. - Moved move spam related code into Spammable concern
* Complete refactor of the `Spammable` concern and tests:Patricio Cano2016-08-151-0/+2
| | | | | | | - Merged `AkismetSubmittable` into `Spammable` - Clean up `SpamCheckService` - Added tests for `Spammable` - Added submit (ham or spam) options to `AkismetHelper`
* Lay the ground works to submit information to AkismetPatricio Cano2016-08-151-0/+1
| | | | | | - New concern `AkismetSubmittable` to allow issues and other `Spammable` models to be submitted to Akismet. - New model `UserAgentDetail` to store information needed for Akismet. - Services needed for their creation and tests.
* Added concern for a faster "cache_key" methodfaster-cache-keysYorick Peterse2016-08-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This concern provides an optimized/simplified version of the "cache_key" method. This method is about 9 times faster than the default "cache_key" method. The produced cache keys _are_ different from the previous ones but this is worth the performance improvement. To showcase this I set up a benchmark (using benchmark-ips) that compares FasterCacheKeys#cache_key with the regular cache_key. The output of this benchmark was: Calculating ------------------------------------- cache_key 4.825k i/100ms cache_key_fast 21.723k i/100ms ------------------------------------------------- cache_key 59.422k (± 7.2%) i/s - 299.150k cache_key_fast 543.243k (± 9.2%) i/s - 2.694M Comparison: cache_key_fast: 543243.4 i/s cache_key: 59422.0 i/s - 9.14x slower To see the impact on real code I applied these changes and benchmarked Issue#referenced_merge_requests. For an issue referencing 10 merge requests these changes shaved off between 40 and 60 milliseconds.
* Method for returning issues readable by a userability-batch-issue-checkingYorick Peterse2016-07-291-0/+28
| | | | | | | | | | | | | The method Ability.issues_readable_by_user takes a list of users and an optional user and returns an Array of issues readable by said user. This method in turn is used by Banzai::ReferenceParser::IssueParser#nodes_visible_to_user so this method no longer needs to get all the available abilities just to check if a user has the "read_issue" ability. To test this I benchmarked an issue with 222 comments on my development environment. Using these changes the time spent in nodes_visible_to_user was reduced from around 120 ms to around 40 ms.
* Refactor spam validation to a concern that can be easily reused and improve ↵akismet-ui-checkPatricio Cano2016-07-261-0/+1
| | | | legibility in `SpamCheckService`
* Refactor user authorization check for a single project to avoid querying all ↵Alejandro Rodríguez2016-07-201-0/+40
| | | | | | | | | | user projects Currently, even when searching for all authorized issues of *one* project, we run the `Users#authorized_projects` query (which can be rather slow). This update checks if we are handling issues of just one project and does the authorization check locally. It does have the downside of basically repeating the logic of `Users#authorized_projects` on `Project#authorized_for_user`.
* use has_many relationship with eventsJames Lopez2016-07-011-1/+2
|
* fixing events for import/exportJames Lopez2016-06-291-0/+1
|
* Fix RangeError exceptions when referring to issues or merge requests outside ↵Stan Hu2016-06-181-0/+4
| | | | | | | | | | of max database values When using #XYZ in Markdown text, if XYZ exceeds the maximum value of a signed 32-bit integer, we get an exception when the Markdown render attempts to run `where(iids: XYZ)`. Introduce a method that will throw out out-of-bounds values. Closes #18777
* Use Issue.visible_to_user in Notes.search to avoid query duplicationDouglas Barbosa Alexandre2016-06-131-1/+1
|
* Project members with guest role can't access confidential issuesDouglas Barbosa Alexandre2016-06-131-1/+9
|
* Improve Issuable.order_labels_priorityRémy Coutable2016-06-061-2/+2
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Refactor ParticipableYorick Peterse2016-06-011-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are several changes to this module: 1. The use of an explicit stack in Participable#participants 2. Proc behaviour has been changed 3. Batch permissions checking == Explicit Stack Participable#participants no longer uses recursion to process "self" and all child objects, instead it uses an Array and processes objects in breadth-first order. This allows us to for example create a single Gitlab::ReferenceExtractor instance and pass this to any Procs. Re-using a ReferenceExtractor removes the need for running potentially many SQL queries every time a Proc is called on a new object. == Proc Behaviour Changed Previously a Proc in Participable was expected to return an Array of User instances. This has been changed and instead it's now expected that a Proc modifies the Gitlab::ReferenceExtractor passed to it. The return value of the Proc is ignored. == Permissions Checking The method Participable#participants uses Ability.users_that_can_read_project to check if the returned users have access to the project of "self" _without_ running multiple SQL queries for every user.
* Remove the annotate gem and delete old annotationsJeroen van Baarsen2016-05-091-24/+0
| | | | | | | | | In 8278b763d96ef10c6494409b18b7eb541463af29 the default behaviour of annotation has changes, which was causing a lot of noise in diffs. We decided in #17382 that it is better to get rid of the whole annotate gem, and instead let people look at schema.rb for the columns in a table. Fixes: #17382
* Annotate the modelsZeger-Jan van de Weg2016-05-061-3/+6
|
* Move Issue scopes from Issuable to Issue modelRémy Coutable2016-04-201-0/+4
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Move due_date sort scopes to Issue and fix CHANGELOGRémy Coutable2016-04-201-0/+12
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Address MR feedbackRémy Coutable2016-04-201-11/+7
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Add red color to overdue and open issuesMehmet Beydogan2016-04-201-0/+8
|
* Fix functionality of due this week. Add due this month and overdue, remove ↵Mehmet Beydogan2016-04-201-2/+6
| | | | | | | due tomorrow to issues. Fix typos on sorting dropdown related to due date Remove constant array and add Structs on Issue to keep due date data to fill options
* Add due_date:time field to Issue modelMehmet Beydogan2016-04-201-0/+3
| | | | | | | | | | | Add due_date text field to sidebar issue#show Add ability sorting issues by due date ASC and DESC Add ability to filtering issues by No Due Date, Any Due Date, Due to tomorrow, Due in this week options Add handling issue due_date field for MergeRequest Update CHANGELOG Fix ambigous match for issues#show sidebar Fix SCREAMING_SNAKE_CASE offenses for due date contants Add specs for due date sorting and filtering on issues
* Merge branch '15139-fix-constants-redefinition-warnings' into 'master' Robert Speicher2016-04-191-1/+0
|\ | | | | | | | | | | | | Define constants only if not defined yet and freeze them Fixes #15139. See merge request !3810
| * Remove useless require 'file_size_validator' causing warningsRémy Coutable2016-04-191-1/+0
| | | | | | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* | A new branch created for a confidential issue is named ↵14566-confidential-issue-branchesTimothy Andrew2016-04-191-1/+1
| | | | | | | | `<id>-confidential-issue`.
* | Merge remote-tracking branch 'origin/master' into ↵Timothy Andrew2016-04-151-4/+3
|\ \ | |/ | | | | 14566-confidential-issue-branches
| * Start with iid on branch creationZeger-Jan van de Weg2016-04-141-2/+2
| |
* | Refactor `Issue#related_branches`Timothy Andrew2016-04-121-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Previously, the controller held the logic to calculate related branches, which was: `<branches ending with `issue.iid`> - <branches with a merge request referenced in the current issue>` - This logic belongs in the `related_branches` method, not in the controller. This commit makes this change. - This means that `Issue#related_branches` now needs to take a `User`. When we find the branches that have a merge request referenced in the current issue, this is limited to merge requests that the current user has access to. - This is not directly related to #14566, but is a related refactoring.
* | Sanitize branch names for confidential issues.Timothy Andrew2016-04-121-1/+5
|/ | | | | | | - When creating new branches for confidential issues, prefer a branch name like `issue-15` to `some-sensitive-issue-title-15`. - The behaviour for non-confidential issues stays the same.
* Memoize reference_pattern/link_reference_patternmemoize-pattern-methodsYorick Peterse2016-04-011-2/+2
| | | | | These methods are called quite often in loops so by memoizing their output we can reduce timings a bit.
* Do not allow to move issue if it has not been persistedmove-issue-section-should-not-be-displayed-in-the-new-issue-form-14489Grzegorz Bizon2016-03-231-1/+2
|
* Merge branch 'master' into issue_12658Douwe Maan2016-03-211-3/+18
|\ | | | | | | | | | | | | | | | | # Conflicts: # app/models/issue.rb # app/views/projects/_home_panel.html.haml # app/views/shared/projects/_project.html.haml # db/schema.rb # spec/models/project_spec.rb
| * Merge branch 'issues-show-performance' into 'master' Robert Speicher2016-03-211-3/+3
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve performance of viewing individual issues This MR does two things: 1. `Issue#related_branches` no longer performs Git operations that aren't needed 2. The output of `Repository#exists?` is now cached and flushed properly Combined these two changes should further cut down the amount of Git operations performed when viewing individual issues (and possibly other pages). See merge request !3296
| | * Tweaked performance of Issue#related_branchesYorick Peterse2016-03-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Requesting the branch names of a repository works even when it's empty, thus there's no need to explicitly check for an empty repository. Removing this check cuts down the amount of Git operations which in turn cuts down request timings a bit. The regular expression used to compare branches was also moved out of the loop so it's created only once.
| * | Merge branch 'master' into feature/issue-moveGrzegorz Bizon2016-03-201-4/+3
| |\ \ | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: Fix bug where wrong commit ID was being used in a merge request diff to show old image Remove CHANGELOG item that was added during merge resolution Improve the "easy WIP & un-WIP from link" feature Fix specs \#to_branch_name now uses the iid as postfix Add label description in tooltip to labels in issue index and sidebar Easily (un)mark merge request as WIP using link Use specialized system notes when MR is (un)marked as WIP another attempt to fix oauth issue attempting to fix omniauth problem Conflicts: app/assets/javascripts/issuable_form.js.coffee
| * | Merge branch 'master' into feature/issue-moveGrzegorz Bizon2016-03-191-5/+33
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (121 commits) Dedupe labels in labels selector in Dashboard pages Refactor colors and lists Add a safeguard in MergeRequest#compute_diverged_commits_count Fix an issue when the target branch of a MR had been deleted Add avatar to issue and MR pages header Cleanup somce css colors Re-group scss variables Refactor `Todo#target` Fixes issue with filter label missing on labels & milestones Rename `Todo#to_reference` to `Todo#target_reference` Fixed failing tests Updated controller with before_action Fixed other issues based on feedback Fixes issue on dashboard issues Full labels data in JSON Fixed issue with labels dropdown getting wrong labels Update CHANGELOG Use `Note#for_project_snippet?` to skip notes on project snippet Use `Commit#short_id` instead of `Commit.truncate_sha` Reuse `for_commit?` on conditional validations Update schema info comment on todo related files ... Conflicts: app/models/issue.rb db/schema.rb spec/models/issue_spec.rb