Project

General

Profile

Actions

Defect #33952

closed

Spent time details are displayed in incorrect order when sorted by week and date

Added by Yuichi HARADA over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Time tracking
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
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

Files

customquery.png (93.1 KB) customquery.png Yuichi HARADA, 2020-09-03 04:21
spenttime-with-customquery.png (144 KB) spenttime-with-customquery.png Yuichi HARADA, 2020-09-03 04:21
fixed-33952.patch (2.83 KB) fixed-33952.patch Yuichi HARADA, 2020-09-03 04:52
33952-v2.patch (2.79 KB) 33952-v2.patch Go MAEDA, 2020-12-10 15:20
Actions #1

Updated by Yuichi HARADA over 3 years 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),
Actions #2

Updated by Yuichi HARADA over 3 years 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),
Actions #3

Updated by Go MAEDA over 3 years ago

  • Status changed from New to Confirmed
Actions #4

Updated by Go MAEDA over 3 years ago

  • Target version set to Candidate for next minor release
Actions #5

Updated by Go MAEDA over 3 years ago

  • Target version changed from Candidate for next minor release to 4.1.2

I have slightly updated the test code.

Setting the target version to 4.1.2.

Actions #6

Updated by Go MAEDA over 3 years ago

Go MAEDA wrote:

I have slightly updated the test code.

I forgot to attach a patch.

Actions #7

Updated by Go MAEDA over 3 years ago

  • Subject changed from Sorting of Week column and Date column does not work to Sorting spent time details by week and date does not work
Actions #8

Updated by Go MAEDA over 3 years ago

  • Subject changed from Sorting spent time details by week and date does not work to Spent time details are displayed in incorrect order when sorted by week and date
  • Status changed from Confirmed to Closed
  • Assignee set to Go MAEDA
  • Target version changed from 4.1.2 to 4.2.0
  • Resolution set to Fixed

Committed the patch. Thank you.

Actions

Also available in: Atom PDF