issue_query.v3.diff

Toshi MARUYAMA, 2017-08-18 05:53

Download (1.75 KB)

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
      pluck(:id)
369
  rescue ::ActiveRecord::StatementInvalid => e
370
    raise StatementInvalid.new(e.message)
371
  end    
372

  
362 373
  def sql_for_updated_by_field(field, operator, value)
363 374
    neg = (operator == '!' ? 'NOT' : '')
364 375
    subquery = "SELECT 1 FROM #{Journal.table_name}" +
......
426 437

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

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

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

  
447
    version_ids = version_ids(:conditions => [where])
439 448
    nl = operator == "!*" ? "#{Issue.table_name}.fixed_version_id IS NULL OR" : ''
440 449
    "(#{nl} #{sql_for_field("fixed_version_id", "=", version_ids, Issue.table_name, "fixed_version_id")})"
441 450
  end