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

Report & discuss bugs found in SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
o123456789
Newbie
Newbie
Posts: 1
Joined: February 22nd, 2013, 6:35 pm

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

Post 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.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

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

Post by shypike »

I'll look into this.
The idea was to sort on timestamp, could be that we messed it up.
Post Reply