Project

General

Profile

Patch #21583 » project_nicer_trackers_query.diff

Ondřej Ezr, 2015-12-22 01:28

View differences:

app/models/project.rb
414 414
  def rolled_up_trackers
415 415
    @rolled_up_trackers ||=
416 416
      Tracker.
417
        joins(:projects).
418
        joins("JOIN #{EnabledModule.table_name} ON #{EnabledModule.table_name}.project_id = #{Project.table_name}.id AND #{EnabledModule.table_name}.name = 'issue_tracking'").
417
        joins(projects: :enabled_modules).
419 418
        where("#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> ?", lft, rgt, STATUS_ARCHIVED).
419
        where("#{EnabledModule.table_name}.name = ?", 'issue_tracking').
420 420
        uniq.
421 421
        sorted.
422 422
        to_a
    (1-1/1)