Skip to content
Snippets Groups Projects

[WIP] Moves the stage and ref from the table in a ci commit build to a plain one line text

Closed Tiago Botelho requested to merge tiagonbotelho/gitlab-ce:ci-commit into master
1 file
+ 2
2
Compare changes
  • Side-by-side
  • Inline
  • 163cff87
    Optimize Project#ci_service(s) · 163cff87
    Yorick Peterse authored
    The method Project#ci_services would load all services into memory
    (including _all_ their columns) and then use Enumerable#select to reduce
    the list. Project#ci_service in turn would further reduce this list down
    to just 1 Service instance.
    
    Instead of doing all this in Ruby we can just offload the work to the
    database, reducing the amount of time spent in these methods. These
    changes reduce the time of the first call to Project#ci_services from
    around 240 ms to around 10 ms, though the final timings will vary based
    on database load. Because Project#ci_service is memoized there's no
    further overhead introduced by using a database query.
    
    Fixes gitlab-org/gitlab-ce#14186
+ 2
2
@@ -528,11 +528,11 @@ def find_service(list, name)
@@ -528,11 +528,11 @@ def find_service(list, name)
end
end
def ci_services
def ci_services
services.select { |service| service.category == :ci }
services.where(category: :ci)
end
end
def ci_service
def ci_service
@ci_service ||= ci_services.find(&:activated?)
@ci_service ||= ci_services.reorder(nil).find_by(active: true)
end
end
def jira_tracker?
def jira_tracker?
Loading