gitlab-org--gitlab-foss/app/models
Yorick Peterse b4ee6f57b9 Greatly improve external_issue_tracker performance
This greatly improves the performance of Project#external_issue_tracker
by moving most of the fields queried in Ruby to the database and letting
the database handle all logic. Prior to this change the process of
finding an external issue tracker was along the lines of the following:

1. Load all project services into memory.
2. Reduce the list to only services where "issue_tracker?" returns true
3. Reduce the list from step 2 to service where "default?" returns false
4. Find the first service where "activated?" returns true

This has to two big problems:

1. Loading all services into memory only to reduce the list down to a
   single item later on is a waste of memory (and slow timing wise).
2. Calling Array#select followed by Array#reject followed by Array#find
   allocates extra objects when this really isn't needed.

To work around this the following service fields have been moved to the
database (instead of being hardcoded):

* category
* default

This in turn means we can get the external issue tracker using the
following query:

    SELECT *
    FROM services
    WHERE active IS TRUE
    AND default IS FALSE
    AND category = 'issue_tracker'
    AND project_id = XXX
    LIMIT 1

This coupled with memoizing the result (just as before this commit)
greatly reduces the time it takes for Project#external_issue_tracker to
complete. The exact reduction depends on one's environment, but locally
the execution time is reduced from roughly 230 ms to only 2 ms (= a
reduction of almost 180x).

Fixes gitlab-org/gitlab-ce#10771
2016-01-19 14:03:20 +01:00
..
ci Merge branch 'ci/build_dependencies' into 'master' 2016-01-15 15:54:35 +00:00
concerns Merge branch 'unsubscribe-from-thread-from-email-footer' into 'master' 2016-01-14 14:38:55 +00:00
hooks Raise hook url limit 2016-01-15 00:35:12 +03:00
members
network
project_services Greatly improve external_issue_tracker performance 2016-01-19 14:03:20 +01:00
.gitkeep
ability.rb Give reporters the ability to download artifacts. 2016-01-15 12:01:19 +01:00
abuse_report.rb Use a more sensible message for the AbuseReport uniqueness validation 2016-01-16 16:50:43 -05:00
application_setting.rb Annotate models 2016-01-06 13:09:55 +00:00
audit_event.rb
broadcast_message.rb Move `BroadcastMessage#status` to a helper since it's presentational 2016-01-13 11:49:59 -05:00
commit.rb Merge branch 'master' into tmp-reference-pipeline-and-caching 2015-12-10 14:04:34 +01:00
commit_range.rb Satisfy Rubocop 2015-12-02 10:54:24 +01:00
commit_status.rb Merge branch 'ci/api-builds' into 'master' 2016-01-14 16:29:15 +00:00
deploy_key.rb
deploy_keys_project.rb
diff_line.rb
email.rb
event.rb Don't show project fork event as imported 2015-12-02 10:56:05 +01:00
external_issue.rb
forked_project_link.rb
generic_commit_status.rb Annotate models 2016-01-06 13:09:55 +00:00
global_label.rb Refactor global and group milestones logic 2015-11-16 14:07:38 +01:00
global_milestone.rb Add two custom Date/Time conversion formats 2016-01-07 20:01:08 -05:00
group.rb Annotate models 2016-01-06 13:09:55 +00:00
identity.rb Codestyle changes 2016-01-12 12:29:10 -02:00
issue.rb Show referenced MRs & Issues only when the current viewer can access them 2016-01-13 11:59:10 +01:00
jira_issue.rb Backport JIRA service 2015-12-18 14:19:48 -06:00
key.rb
label.rb Add custom ColorValidator 2015-12-07 16:57:26 -05:00
label_link.rb
lfs_object.rb Update annotations 2015-12-08 21:00:01 -08:00
lfs_objects_project.rb Update annotations 2015-12-08 21:00:01 -08:00
member.rb Refactor ability changes 2015-11-17 15:49:37 +01:00
merge_request.rb Merge branch 'group-issues-sorting' into 'master' 2016-01-11 15:28:41 +00:00
merge_request_diff.rb Add ignore white space option in merge request diff 2015-11-13 16:53:53 +09:00
milestone.rb Add two custom Date/Time conversion formats 2016-01-07 20:01:08 -05:00
namespace.rb Annotate models 2016-01-06 13:09:55 +00:00
note.rb Move complex view condition to a model method 2016-01-13 16:37:17 +01:00
notification.rb Added Global to the drop downs and updated the label of the button to show the current level instead of `Notifications` 2015-09-16 19:46:24 -05:00
personal_snippet.rb
project.rb Greatly improve external_issue_tracker performance 2016-01-19 14:03:20 +01:00
project_import_data.rb
project_snippet.rb
project_team.rb Improve ProjectTeam#max_member_access performance 2015-10-15 12:05:01 +02:00
project_wiki.rb Add Banzai::Filter::GollumTagsFilter for parsing Gollum's tags in HTML 2016-01-14 12:09:31 -02:00
protected_branch.rb
release.rb Annotate models 2015-11-13 19:22:46 +01:00
repository.rb Add support for ref and path to commits filtering 2016-01-07 15:16:11 +01:00
security_event.rb
sent_notification.rb #can_unsubscribe? -> #?unsubscribable? 2016-01-11 14:23:45 +01:00
service.rb Greatly improve external_issue_tracker performance 2016-01-19 14:03:20 +01:00
snippet.rb Autolink first so we don't pick up numeric anchors as issue references. 2015-12-01 15:53:32 +01:00
subscription.rb
tree.rb Validate README format before displaying 2016-01-05 11:06:18 -02:00
user.rb fixed LDAP activation on login to use new ldap_blocked state 2016-01-14 03:31:27 -02:00
users_star_project.rb Touch project when toggling stars to update cache 2015-12-03 16:08:08 -02:00
wiki_page.rb Relax constraints for wiki slug 2016-01-14 12:09:31 -02:00