Last modified: 2012-02-12 14:20:10 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T27768, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 25768 - Date returned by query gets treated like string with respect to sorting in table
Date returned by query gets treated like string with respect to sorting in table
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Markus Krötzsch
:
: 25807 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-11-03 18:52 UTC by skew
Modified: 2012-02-12 14:20 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description skew 2010-11-03 18:52:39 UTC
I've got pages that each have multiple SIO records, and each record includes a date (Status Report Date of type Date).  I was able to create a 2 column summary table that lists each page along with the date of the newest record with this query:
<pre>
{{#ask:[[Category:Status Report]] [[Has Contributor::{{PAGENAME}}]]
|?Has Effort=Effort
|link=none
|sort=Has Effort
|format=template
|template=display2ColTableViewStatusReportEntry
|intro={{display2ColSortTableHeader |col1=Effort |col2=Last Update}}
|outro={{displayTableFooter}}
}} 
</pre>

where Template:display2ColTableViewStatusReportEntry holds
<pre>

| [[{{{1}}}#{{#ask: [[Status Report Record::{{{1}}}]] |?Has Status Report Date= |sort=Has Status Report Date |format=list |limit=1 |order=descending |mainlabel=- |link=none |headers=hide |searchlabel= }}|{{{2}}} - View]]
| {{#ask: [[Status Report Record::{{{1}}}]] |?Has Status Report Date= |sort=Has Status Report Date |format=list |limit=1 |order=descending |mainlabel=- |link=none |headers=hide |searchlabel= }}
|-
</pre>

This results in a column sort table like
<pre>
      Effort             v Last Update 
Soda Project - View	 4 November 2010
Burger Project - View	 25 October 2010
Hot Dog Project - View	 20 May 2010
Sandwich Project - View	 19 October 2010
</pre>
The table shown above replicates one sorted by Last Update in descending order.  It sorts alphanumerically rather than by date.
Comment 1 Dan Bolser 2010-11-06 19:34:13 UTC

*** This bug has been marked as a duplicate of bug 25807 ***
Comment 2 Markus Krötzsch 2012-02-11 22:42:02 UTC
*** Bug 25807 has been marked as a duplicate of this bug. ***
Comment 3 Markus Krötzsch 2012-02-11 23:01:57 UTC
First, this bug is not "critical". Mainly, the issue is a basic limitation of the "recipe" at [1] and this recipe should warn about this. SMW takes special precautions to avoid this problem in its own tables. By using a manually created table, this special handling is eliminated.

The sortable table code of MediaWiki cannot handle dates. To make them sort properly, one needs to provide numeric sortkeys using the "data-sort-value" attribute in td elements (look at the HTML of any real SMW table for examples). When manually creating tables, one is in charge of providing this information, or one needs to use JavaScript that can handle dates natively (which is difficult due to the complex format). To allow this to be done manually, I have now (in r111269) added a new output format "sortkey" to Type:Date by which one can obtain a numeric sortkey as needed for "data-sort-value". For example, the following query displays dates and their sortkeys:

{{#ask: [[Modification date::+]]
| ?Modification date
| ?Modification date#sortkey
}}

For properties that can have many values, only one sortkey must be used (since the whole table row is sorted as one, even if many dates are in one cell). This can be achieved by using +limit like so:

{{#ask: [[testdate::+]]
| ?testdate
| ?testdate#sortkey |+limit=1
}}

It would be nice if the recipe could be extended by all this information, and ideally with a recipe for building the correct HTML code. This goes as far as SMW can assist the manual creation of sortable tables, so I am closing this bug.

[1] http://smw.referata.com/wiki/Use_the_ask_template_format_to_create_tabular_output
Comment 4 Dan Bolser 2012-02-12 14:20:10 UTC
The best would be to make the recipe obsolete by implementing some better 'format results' syntax, but I see that this is not easy.

In the meantime, I'll just put a pointer there to here.


Cheers,

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links