Bug 802901 - Sorting on 'Scheduled Time' does not sort by Date & Time
Sorting on 'Scheduled Time' does not sort by Date & Time
Status: CLOSED CURRENTRELEASE
Product: Spacewalk
Classification: Community
Component: WebUI (Show other bugs)
1.8
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Stephen Herr
Red Hat Satellite QA List
:
Depends On:
Blocks: space18
  Show dependency treegraph
 
Reported: 2012-03-13 13:30 EDT by Stephen Herr
Modified: 2012-11-01 12:22 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 755470
Environment:
Last Closed: 2012-11-01 12:22:02 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Stephen Herr 2012-03-13 13:30:07 EDT
+++ This bug was initially created as a clone of Bug #755470 +++

Description of problem:
Going to Schedule tab and checking through Archived actions, unable to sort the list by Scheduled Time.  The column header is sortable, but the end result looks like an alphabetical sort rather than a date sort.

Page is: rhn/schedule/ArchivedActions.do

Result example:

10/10/11 time
10/10/11 time
10/11/11 time
10/11/11 time
10/11/11 time
10/20/11 time
10/20/11 time
10/20/11 time
10/26/11 time
10/26/11 time
10/3/11 time
10/3/11 time
10/5/11 time

Version-Release number of selected component (if applicable):
RHN Satellite v5.4.1

How reproducible:
Always

Steps to Reproduce:
1. Login to Satellite -> Go to Schedule tab
2. Click on 'Scheduled Time' to sort the results based on this column
  
Actual results:
Sorting is not as per the date

Expected results:
Sorting should be as per the date & time under 'Scheduled Time'

--- Additional comment from pmutha@redhat.com on 2011-11-21 04:09:46 EST ---

======= Engineering =======

Looking into the code, here is what I see :

spacewalk/java/code/src/com/redhat/rhn/frontend/action/schedule/ArchivedActionsSetupAction.java

    /** 
     *  
     * {@inheritDoc}
     */ 
    public List getResult(RequestContext context) {
        return ActionManager.archivedActions(context.getCurrentUser(), null);
    }   

Here we are using ListHelper

spacewalk/java/code/src/com/redhat/rhn/manager/action/ActionManager.java

     /**
     * Helper method that does the work of getting a specific
     * DataResult for scheduled actions.
     * @param user The user in question
     * @param pc The details of which results to return
     * @param mode The mode
     * @return Returns a list containing the actions for the user
     */
    private static DataResult getActions(User user, PageControl pc, String mode,
            String setLabel) {
        SelectMode m = ModeFactory.getMode("Action_queries", mode);
        Map params = new HashMap();
        params.put("user_id", user.getId());
        params.put("org_id", user.getOrg().getId());
        if (setLabel != null) {
            params.put("set_label", setLabel);
        }
        if (pc != null) {
            return makeDataResult(params, params, pc, m);
        }
        DataResult dr = m.execute(params);
        dr.setTotalSize(dr.size());
        dr.setElaborationParams(params);
        return dr;
    }


spacewalk/web/modules/rhn/RHN/DB/DataSource/xml/Action_queries.xml

<mode name="archived_action_list">
  <query params="user_id, org_id">
SELECT  DISTINCT UAO.id AS ID,
        TO_CHAR(UAO.earliest_action, 'YYYY-MM-DD HH24:MI:SS') AS EARLIEST,
        UAO.type_name,
        (CASE UAO.action_name WHEN NULL THEN UAO.type_name ELSE UAO.action_name END) AS ACTION_NAME
  FROM  rhnUserActionOverview UAO
 WHERE  UAO.org_id = :org_id
   AND  UAO.user_id = :user_id
   AND  UAO.archived = 1
ORDER BY EARLIEST DESC
  </query>

Checking the spacewalk/java/code/webapp/WEB-INF/pages/schedule/archivedactions.jsp we see :

                <rl:column sortable="true"
                                   bound="false"
                           headerkey="actions.jsp.earliest"
                           sortattr="earliest" >
                        <c:out value="${current.earliest}" />
                </rl:column>


In the database query, TO_CHAR is converting the date & time into VARCHAR2 datatype and further ListHelper is being used. We can't see anywhere the earliest being converted into date from char. I doubt if this is leading to sorting of the timestamp as a string instead of timestamp. I have attached the screenshot of the Archived Actions page where we can see that sorting is not done as expected.

Similar bugs :
https://bugzilla.redhat.com/show_bug.cgi?id=508771
https://bugzilla.redhat.com/show_bug.cgi?id=722453
https://bugzilla.redhat.com/show_bug.cgi?id=574594

--- Additional comment from pmutha@redhat.com on 2011-11-21 04:16:16 EST ---

Internal Reproducer details :
----------------------------

https://agonda.gsslab.pnq.redhat.com/rhn/schedule/ArchivedActions.do
satadmin/redpsace root/redspace

Sort in ascending order (.v.)
Errata Update: RHBA-2009:1573-3 - vconfig bug fix update 	8/25/11 3:16:09 AM EDT 	1 	0 	0 	1
Errata Update: RHBA-2009:0453-3 - tcp_wrappers bug fix update 	8/25/11 7:51:14 PM EDT 	1 	0 	0 	1
Errata Update: RHBA-2011:0759-1 - mdadm bug fix and enhancement update 	8/25/11 9:54:22 PM EDT 	1 	0 	0 	1
Initiate a kickstart 	8/8/11 12:45:03 AM EDT 	0 	1 	0 	1

So here timestamps are :
8/25/11 3:16:09 AM EDT
8/25/11 7:51:14 PM EDT 
8/25/11 9:54:22 PM EDT
8/8/11 12:45:03 AM EDT   <-- this should have been first as the sort was in ascending order.

--- Additional comment from sherr@redhat.com on 2012-03-13 13:28:47 EDT ---

Fixed in Spacewalk master, 8a5693042f5c751379aea80d618e3c140646454d
Comment 2 Jan Pazdziora 2012-06-15 10:00:36 EDT
This is Spacewalk bugzilla -- could we have it public?
Comment 3 Stephen Herr 2012-06-18 10:05:09 EDT
Yes, Bugzilla clones things by default to have the same permissions as the original bug, I must have forgotten to change them to public on this one.
Comment 4 Jan Pazdziora 2012-10-30 15:27:07 EDT
Moving ON_QA. Packages that address this bugzilla should now be available in yum repos at http://yum.spacewalkproject.org/nightly/
Comment 5 Jan Pazdziora 2012-11-01 12:22:02 EDT
Spacewalk 1.8 has been released: https://fedorahosted.org/spacewalk/wiki/ReleaseNotes18

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