Merge lp://staging/~zematynnad/ubuntu-webcatalog/duplicates_987826 into lp://staging/ubuntu-webcatalog
Proposed by
Danny Tamez
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Anthony Lenton | ||||
Approved revision: | 127 | ||||
Merged at revision: | 122 | ||||
Proposed branch: | lp://staging/~zematynnad/ubuntu-webcatalog/duplicates_987826 | ||||
Merge into: | lp://staging/ubuntu-webcatalog | ||||
Diff against target: |
93 lines (+41/-10) 2 files modified
src/webcatalog/tests/test_views.py (+26/-5) src/webcatalog/views.py (+15/-5) |
||||
To merge this branch: | bzr merge lp://staging/~zematynnad/ubuntu-webcatalog/duplicates_987826 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Anthony Lenton (community) | Approve | ||
Review via email: mp+107091@code.staging.launchpad.net |
Commit message
Removes duplicate apps from top rated apps widget.
Description of the change
Overview
=========
This branch is a fix for http://
Details
========
The problem was that apps for the same package but for different distroseries were being returned in the query. Since django doesn't do distinct on individual fields (at least not without a patch) the duplicates have to be filtered out a different way. I just used a dictionary with the packagename as the key to avoid the duplicates.
To Test
========
$fab bootstrap test
To post a comment you must log in.
Hi Danny,
I really don't think the code is doing what we want there. Comments about the changes in src/webcatalog/ views.py: NUMBER_ TOP_RATED_ APPS off the filtered list (tens of apps). See if there's a way to only filter enough apps as we need.
- You iterate over all of top_rated_apps (tens of thousands of apps) to keep just the first settings.
- For each package name you currently keep the last item on the list that matches the name (as the dict is overridden each time you find a new Application instance with the same package name), so I you're effectively keeping the *lowest* rated app instance for each package name.
- Finally, you're storing the apps in a dict and then asking for values(), so you can't expect any order in top_rated_apps.
- And, something really minor, Count is being imported unnecessarily.
Kind regards,
achuni.