From 99e8f7e3cb43d0a1a67e805de82d201e87fdad5b Mon Sep 17 00:00:00 2001 From: aignatov-bio <47317017+aignatov-bio@users.noreply.github.com> Date: Mon, 28 Feb 2022 11:16:29 +0100 Subject: [PATCH] Fix added on this month filter [SCI-6584] (#3904) Co-authored-by: Anton --- app/services/repository_datatable_service.rb | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/services/repository_datatable_service.rb b/app/services/repository_datatable_service.rb index caf51b12d..de7824908 100644 --- a/app/services/repository_datatable_service.rb +++ b/app/services/repository_datatable_service.rb @@ -202,7 +202,7 @@ class RepositoryDatatableService ) when 'this_month' repository_rows.where( - "date_trunc('minute', \"created_at\") >= ? AND date_trunc('minute', \"created_at\") <= ?", + "date_trunc('minute', \"repository_rows\".\"created_at\") >= ? AND date_trunc('minute', \"repository_rows\".\"created_at\") <= ?", Time.zone.now.beginning_of_month, Time.zone.now.end_of_month ) @@ -254,22 +254,22 @@ class RepositoryDatatableService case filter_element_params[:operator] when 'today' - repository_rows.where("date_trunc('minute', \"archived_on\") >= ? AND date_trunc('minute', \"archived_on\") <= ?", + repository_rows.where("date_trunc('minute', \"repository_rows\".\"archived_on\") >= ? AND date_trunc('minute', \"repository_rows\".\"archived_on\") <= ?", Time.zone.now.beginning_of_day, Time.zone.now.end_of_day) when 'yesterday' - repository_rows.where("date_trunc('minute', \"archived_on\") >= ? AND date_trunc('minute', \"archived_on\") < ?", + repository_rows.where("date_trunc('minute', \"repository_rows\".\"archived_on\") >= ? AND date_trunc('minute', \"repository_rows\".\"archived_on\") < ?", Time.zone.now.beginning_of_day - 1.day, Time.zone.now.beginning_of_day) when 'last_week' - repository_rows.where("date_trunc('minute', \"archived_on\") >= ? AND date_trunc('minute', \"archived_on\") < ?", + repository_rows.where("date_trunc('minute', \"repository_rows\".\"archived_on\") >= ? AND date_trunc('minute', \"repository_rows\".\"archived_on\") < ?", Time.zone.now.beginning_of_week - 1.week, Time.zone.now.beginning_of_week) when 'this_month' repository_rows.where( - "date_trunc('minute', \"archived_on\") >= ? AND date_trunc('minute', \"archived_on\") <= ?", + "date_trunc('minute', \"repository_rows\".\"archived_on\") >= ? AND date_trunc('minute', \"repository_rows\".\"archived_on\") <= ?", Time.zone.now.beginning_of_month, Time.zone.now.end_of_month ) when 'last_year' - repository_rows.where("date_trunc('minute', \"archived_on\") >= ? AND date_trunc('minute', \"archived_on\") < ?", + repository_rows.where("date_trunc('minute', \"repository_rows\".\"archived_on\") >= ? AND date_trunc('minute', \"repository_rows\".\"archived_on\") < ?", Time.zone.now.beginning_of_year - 1.year, Time.zone.now.beginning_of_year) when 'this_year' repository_rows.where( @@ -279,25 +279,25 @@ class RepositoryDatatableService Time.zone.now.end_of_year ) when 'equal_to' - repository_rows.where("date_trunc('minute', \"archived_on\") = ?", + repository_rows.where("date_trunc('minute', \"repository_rows\".\"archived_on\") = ?", Time.zone.parse(filter_element_params.dig(:parameters, :datetime))) when 'unequal_to' - repository_rows.where.not("date_trunc('minute', \"archived_on\") = ?", + repository_rows.where.not("date_trunc('minute', \"repository_rows\".\"archived_on\") = ?", Time.zone.parse(filter_element_params.dig(:parameters, :datetime))) when 'greater_than' - repository_rows.where("date_trunc('minute', \"archived_on\") > ?", + repository_rows.where("date_trunc('minute', \"repository_rows\".\"archived_on\") > ?", Time.zone.parse(filter_element_params.dig(:parameters, :datetime))) when 'greater_than_or_equal_to' - repository_rows.where("date_trunc('minute', \"archived_on\") >= ?", + repository_rows.where("date_trunc('minute', \"repository_rows\".\"archived_on\") >= ?", Time.zone.parse(filter_element_params.dig(:parameters, :datetime))) when 'less_than' - repository_rows.where("date_trunc('minute', \"archived_on\") < ?", + repository_rows.where("date_trunc('minute', \"repository_rows\".\"archived_on\") < ?", Time.zone.parse(filter_element_params.dig(:parameters, :datetime))) when 'less_than_or_equal_to' - repository_rows.where("date_trunc('minute', \"archived_on\") <= ?", + repository_rows.where("date_trunc('minute', \"repository_rows\".\"archived_on\") <= ?", Time.zone.parse(filter_element_params.dig(:parameters, :datetime))) when 'between' - repository_rows.where("date_trunc('minute', \"archived_on\") > ? AND date_trunc('minute', \"archived_on\") < ?", + repository_rows.where("date_trunc('minute', \"repository_rows\".\"archived_on\") > ? AND date_trunc('minute', \"repository_rows\".\"archived_on\") < ?", Time.zone.parse(filter_element_params.dig(:parameters, :start_datetime)), Time.zone.parse(filter_element_params.dig(:parameters, :end_datetime))) else