From 3b0b0a93b2357e20127228a8e9504960c93fa815 Mon Sep 17 00:00:00 2001 From: ulferts Date: Fri, 1 Apr 2022 16:32:14 +0200 Subject: [PATCH] join status explicitly triggered by status filter --- app/models/queries/work_packages/filter/status_filter.rb | 4 ++++ app/models/query/results.rb | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/queries/work_packages/filter/status_filter.rb b/app/models/queries/work_packages/filter/status_filter.rb index fc6857a077..765c9db8fb 100644 --- a/app/models/queries/work_packages/filter/status_filter.rb +++ b/app/models/queries/work_packages/filter/status_filter.rb @@ -65,6 +65,10 @@ class Queries::WorkPackages::Filter::StatusFilter < Queries::WorkPackages::Filte true end + def joins + :status + end + private def all_statuses diff --git a/app/models/query/results.rb b/app/models/query/results.rb index ebbabd5f4f..33d2db44fd 100644 --- a/app/models/query/results.rb +++ b/app/models/query/results.rb @@ -41,9 +41,9 @@ class ::Query::Results def work_package_count work_package_scope .joins(all_filter_joins) - .includes(:status, :project) + .includes(:project) .where(query.statement) - .references(:statuses, :projects) + .references(:projects) .count rescue ::ActiveRecord::StatementInvalid => e raise ::Query::StatementInvalid.new(e.message) @@ -79,7 +79,7 @@ class ::Query::Results end def all_includes - (%i(status project) + + (%i(project) + includes_for_columns(include_columns)).uniq end