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

RESOLVED FIXED

Status

RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: peterbe, Assigned: espressive)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 years ago
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')):
    ...
(Reporter)

Comment 1

5 years ago
I assigned it to you schalk because I git blamed you for the code :)
Assignee: nobody → sneethling

Comment 3

5 years ago
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

Updated

5 years ago
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.