Project

General

Profile

Patch #38198 ยป 0001-Improve-index-usability-for-Project-project_conditio.patch

Holger Just, 2023-01-19 15:23

View differences:

app/models/project.rb
329 329
  # Returns a :conditions SQL string that can be used to find the issues associated with this project.
330 330
  #
331 331
  # Examples:
332
  #   project.project_condition(true)  => "(projects.id = 1 OR (projects.lft > 1 AND projects.rgt < 10))"
332
  #   project.project_condition(true)  => "(projects.lft >= 1 AND projects.rgt <= 10)"
333 333
  #   project.project_condition(false) => "projects.id = 1"
334 334
  def project_condition(with_subprojects)
335
    cond = "#{Project.table_name}.id = #{id}"
336 335
    if with_subprojects
337
      cond = "(#{cond} OR (#{Project.table_name}.lft > #{lft} AND " \
338
               "#{Project.table_name}.rgt < #{rgt}))"
336
      "(" \
337
        "#{Project.table_name}.lft >= #{lft} AND " \
338
        "#{Project.table_name}.rgt <= #{rgt}" \
339
      ")"
340
    else
341
      "#{Project.table_name}.id = #{id}"
339 342
    end
340
    cond
341 343
  end
342 344

  
343 345
  def self.find(*args)
    (1-1/1)