Page 1 of 1

config/rss "Downloaded" sort order [fix?]

Posted: August 14th, 2014, 1:54 am
by o123456789
I have noticed the sort order for the "Downloaded" rss files has always seemed random.

I finally spent some time looking into it and wanted to share what I found.

Version: 0.7.11 [linux source] (source for 0.7.18 has same code)

Reproduce: (assumes you have rss feed setup which has downloaded files)
WebInterface: Classic
Click Config->Rss
Click "Read" button next to feed
Click "Downloaded" tab
Results should be in random-ish order

Details:

interface.py has the following code:

Code: Select all

     # Sort in reverse order of time stamp for 'Done'
     dnames = [job for job in jobs.keys() if jobs[job]['status'] == 'D']
     dnames.sort(lambda x, y: jobs[y].get('timestamp', 0) - jobs[x].get('timestamp', 0))
     done = [xml_name(jobs[job]['title']) for job in dnames]
It is using 'timestamp' but according to rss.py this field is called 'time'. After changing to time I get an error "TypeError: comparison function must return int, not float"

Fix?:

Modified code to the following:
Change timestamp to time and cast to int

Code: Select all

    # Sort in reverse order of time stamp for 'Done'
    dnames = [job for job in jobs.keys() if jobs[job]['status'] == 'D']
    dnames.sort(lambda x, y: int(jobs[y].get('time', 0) - jobs[x].get('time', 0)))
    done = [xml_name(jobs[job]['title']) for job in dnames]
Stop and restarted sabnzbd and it seems to work.


I just wanted to share incase someone else has this issue.

Re: config/rss "Downloaded" sort order [fix?]

Posted: August 29th, 2014, 11:49 am
by shypike
I'll look into this.
The idea was to sort on timestamp, could be that we messed it up.