Edgewall Software
Modify

Opened 12 years ago

Closed 10 years ago

Last modified 9 years ago

#11132 closed enhancement (duplicate)

Sort numeric columns as numbers, not strings

Reported by: chris.nelson.1022@… Owned by:
Priority: normal Milestone:
Component: general Version:
Severity: normal Keywords: field
Cc: leho@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Custom fields don't have a numeric option so when sorting by fields that contain numeric values (like estimatedhours from Timing and Estimation Plugin), you get orders like:

0.0, 1.0, 12.0, 120.0, 16.0, 2.0, 20.0, …

By adding these fields to the numeric_columns setting in trac.ini

[query]
numeric_columns = totalhours, estimatedhours, remaininghours

the ticket queries and reports sort properly.

Attachments (1)

numeric.diff (3.8 KB ) - added by Chris.Nelson@… 12 years ago.
Patch to implement numeric_columns query option.

Download all attachments as: .zip

Change History (8)

by Chris.Nelson@…, 12 years ago

Attachment: numeric.diff added

Patch to implement numeric_columns query option.

comment:1 by Ryan J Ollos <ryan.j.ollos@…>, 12 years ago

Cc: ryan.j.ollos@… added

It looks like a useful feature.

Did you considered solving this by adding a new field type to TracTicketsCustomFields, or adding an option to the text field type to have the value interpreted as numeric? Maybe format = numeric?

I think your patch could be pretty much the same as it is now, except that you'd create the self.numeric_columns list by iterating over the list of dictionaries in self.fields.

One way or another, it seems desirable to directly associate the information in your numeric_columns configuration option with the custom fields configuration options.

Last edited 11 years ago by Ryan J Ollos (previous) (diff)

comment:2 by lkraav <leho@…>, 12 years ago

Cc: leho@… added

in reply to:  1 ; comment:3 by Chris.Nelson@…, 12 years ago

Replying to Ryan J Ollos <ryan.j.ollos@…>:

It looks like a useful feature.

Thanks.

Did you considered solving this by adding a new field type to TracTicketsCustomFields, or adding an option to the text field type to have the value interpreted as numeric? Maybe format = numeric?

No. I'm not that smart. ;-) The basic structure of this patch is a year or two old. We knew Trac internals less well then (we understand them fairly poorly even now) and didn't, necessarily, make good architectural decisions.

I think your patch could be pretty much the same as it is now, except that you'd create the self.numeric_columns list by iterating over the list of dictionaries in self.fields.

One way or another, it seems desirable to directly associate the information in your numeric_columns configuration option with the custom fields configuration options.

But how many other places would I have to touch that make text-oriented assumptions about custom fields?

Last edited 11 years ago by Ryan J Ollos (previous) (diff)

in reply to:  3 comment:4 by Ryan J Ollos <ryan.j.ollos@…>, 12 years ago

Replying to Chris.Nelson@…:

But how many other places would I have to touch that make text-oriented assumptions about custom fields?

Yeah, good point. I suppose the values would continue to be stored in the database as text, and we'd want to do a cast in _fetch_ticket.

comment:5 by Steffen Hoffmann, 12 years ago

Keywords: field added

relate this ticket by keyword, i.e. to pages like FieldRefactoring

Note, that #3080 already requested numeric fields for implementing an ordering schema other than text.

in reply to:  1 comment:6 by Ryan J Ollos, 10 years ago

Cc: ryan.j.ollos@… removed
Milestone: next-dev-1.1.x
Resolution: duplicate
Status: newclosed

Replying to Ryan J Ollos <ryan.j.ollos@…>:

Did you considered solving this by adding a new field type to TracTicketsCustomFields, or adding an option to the text field type to have the value interpreted as numeric? Maybe format = numeric?

#10040 implements this approach, so closing as a duplicate of that ticket.

comment:7 by Ryan J Ollos, 9 years ago

Reporter: changed from Chris.Nelson@… to chris.nelson.1022@…

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.