Closed Bug 874968 Opened 11 years ago Closed 11 years ago

[socorro-crashstats] crashtrends_versions_json() view does not return versions in a predictable order

Categories

(Socorro :: Webapp, task)

x86
macOS
task
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: peterbe, Assigned: espressive)

Details

I noticed that in this commit https://github.com/mozilla/socorro-crashstats/commit/35d8a18c1a80438e89e664ffbcd0363a9cef3a8d there's a line that isn't working::

 https://github.com/mozilla/socorro-crashstats/commit/35d8a18c1a80438e89e664ffbcd0363a9cef3a8d#L8R1189

This call to `sorted()` is pointless since `sorted()` returns a new list::
 
  >>> stuff = [(2, 'two'), (1, 'one'), (3, 'three')]
  >>> sorted(stuff)
  [(1, 'one'), (2, 'two'), (3, 'three')]
  >>> stuff
  [(2, 'two'), (1, 'one'), (3, 'three')]

Also, if you do `sorted()` on something more complex that a list of numbers you need to specify which key to sort on. 

If the intention is to sort the `request.currentversions` on something, the right way would be to use::

 from operator import itemgetter
 for release in sorted(request.currentversions, key=itemgetter('start_date')):
    ...
I assigned it to you schalk because I git blamed you for the code :)
Assignee: nobody → sneethling
Commits pushed to master at https://github.com/mozilla/socorro-crashstats

https://github.com/mozilla/socorro-crashstats/commit/4f6cb4093be0a465b36b7c7e37a8a24196b05d20
remove sorted call as this does nothing and no sorting is required fixes bug 874968

https://github.com/mozilla/socorro-crashstats/commit/3714d55339c3b7ecf9d8bfbd966d44457616880e
Merge pull request #351 from ossreleasefeed/bug874968-versions-not-returned-in-predictable-order

remove sorted call as this does nothing and no sorting is required fixes bug 874968
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.