Defect #33952

Sorting of Week column and Date column does not work

Added by Yuichi HARADA about 1 month ago. Updated about 1 month ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Time tracking
Target version:-
Resolution: Affected version:

Description

When specifying the sorting condition of Week column and Date column in the custom query, it doesn't sort well.

  • Defining a custom query
  • List of spent time with custom query

customquery.png (93.1 KB) Yuichi HARADA, 2020-09-03 04:21

spenttime-with-customquery.png (144 KB) Yuichi HARADA, 2020-09-03 04:21

fixed-33952.patch Magnifier (2.83 KB) Yuichi HARADA, 2020-09-03 04:52

History

#1 Updated by Yuichi HARADA about 1 month ago

The sort condition Date(:spent_on) and Week(:tweek), defined by app/models/time_entry_query.rb( source:trunk/app/models/time_entry_query.rb#L24 ) are the same table columns.

# Date
QueryColumn.new(:spent_on, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :default_order => 'desc', :groupable => true),

# Week
QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :caption => :label_week),

#2 Updated by Yuichi HARADA about 1 month ago

I think the following patch will fix the problem.

diff --git a/app/models/time_entry_query.rb b/app/models/time_entry_query.rb
index c8f8eeaeb..c5c2099ad 100644
--- a/app/models/time_entry_query.rb
+++ b/app/models/time_entry_query.rb
@@ -25,7 +25,7 @@ class TimeEntryQuery < Query
     QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true),
     QueryColumn.new(:spent_on, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :default_order => 'desc', :groupable => true),
     TimestampQueryColumn.new(:created_on, :sortable => "#{TimeEntry.table_name}.created_on", :default_order => 'desc', :groupable => true),
-    QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :caption => :label_week),
+    QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.tyear", "#{TimeEntry.table_name}.tweek"], :caption => :label_week),
     QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement}),
     QueryColumn.new(:user, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
     QueryColumn.new(:activity, :sortable => "#{TimeEntryActivity.table_name}.position", :groupable => true),

Also available in: Atom PDF