Project

General

Profile

Patch #26714 » issue_query.diff

jwjw yy, 2017-08-17 23:21

View differences:

app/models/issue_query.rb
359 359
    raise StatementInvalid.new(e.message)
360 360
  end
361 361

  
362
  def version_ids(options={})
363
    Version.visible.
364
      where(project_statement).
365
      where(options[:conditions]).
366
      includes(:project).
367
      references(:project)
368
  rescue ::ActiveRecord::StatementInvalid => e
369
    raise StatementInvalid.new(e.message)
370
  end    
362 371
  def sql_for_updated_by_field(field, operator, value)
363 372
    neg = (operator == '!' ? 'NOT' : '')
364 373
    subquery = "SELECT 1 FROM #{Journal.table_name}" +
......
426 435

  
427 436
  def sql_for_fixed_version_status_field(field, operator, value)
428 437
    where = sql_for_field(field, operator, value, Version.table_name, "status")
429
    version_ids = versions(:conditions => [where]).map(&:id)
430

  
438
    version_ids = version_ids(:conditions => [where]).pluck(:id)
431 439
    nl = operator == "!" ? "#{Issue.table_name}.fixed_version_id IS NULL OR" : ''
432 440
    "(#{nl} #{sql_for_field("fixed_version_id", "=", version_ids, Issue.table_name, "fixed_version_id")})"
433 441
  end
434 442

  
435 443
  def sql_for_fixed_version_due_date_field(field, operator, value)
436 444
    where = sql_for_field(field, operator, value, Version.table_name, "effective_date")
437
    version_ids = versions(:conditions => [where]).map(&:id)
438

  
445
    version_ids = version_ids(:conditions => [where]).pluck(:id)
439 446
    nl = operator == "!*" ? "#{Issue.table_name}.fixed_version_id IS NULL OR" : ''
440 447
    "(#{nl} #{sql_for_field("fixed_version_id", "=", version_ids, Issue.table_name, "fixed_version_id")})"
441 448
  end
(2-2/3)