Skip to content
Permalink
Browse files

metrics: 'releases' always must be sorted in all loops.

Depending on the tag that you are using, the data may be inconsistent
with the labels. So, all releases lists needs to be sorted in all loops.

Example:
Data stored in my database:
- Fedora 23: 3 bugs
- Fedora 24: 2 bugs
- Fedora 22: 5 bugs

Sorted label array:
- Fedora 22
- Fedora 23
- Fedora 24

Chart result (wrong results):
- Fedora 22: 3 bugs
- Fedora 23: 2 bugs
- Fedora 24: 5 bugs

After this patch:
- Fedora 22: 5 bugs
- Fedora 23: 3 bugs
- Fedora 24: 2 bugs

Signed-off-by: Julio Faracco <jfaracco@br.ibm.com>
  • Loading branch information...
jcfaracco committed Oct 1, 2016
1 parent f13193d commit 487acaaf34b127e0a8c2d29233847a3db06a87b1
Showing with 4 additions and 2 deletions.
  1. +4 −2 bodhi/server/views/metrics.py
@@ -23,8 +23,10 @@ def compute_ticks_and_data(db, releases, update_types):
""" Return the data and ticks to make the stats graph. """
data, ticks = [], []

for i, release in enumerate(sorted(releases, cmp=lambda x, y:
cmp(int(x.version_int), int(y.version_int)))):
releases = sorted(releases, cmp=lambda x, y:
cmp(int(x.version_int), int(y.version_int)))

for i, release in enumerate(releases):
ticks.append([i, release.name])

for update_type, label in update_types.items():

0 comments on commit 487acaa

Please sign in to comment.
You can’t perform that action at this time.