Merge lp://staging/~elachuni/ubuntu-webcatalog/released-by-default into lp://staging/ubuntu-webcatalog

Proposed by Anthony Lenton
Status: Merged
Approved by: Michael Nelson
Approved revision: 173
Merged at revision: 169
Proposed branch: lp://staging/~elachuni/ubuntu-webcatalog/released-by-default
Merge into: lp://staging/ubuntu-webcatalog
Diff against target: 251 lines (+117/-36)
6 files modified
src/webcatalog/management/commands/check_all_latest.py (+30/-12)
src/webcatalog/managers.py (+18/-8)
src/webcatalog/tests/test_commands.py (+28/-0)
src/webcatalog/tests/test_managers.py (+39/-14)
src/webcatalog/tests/test_models_oauth.py (+1/-1)
src/webcatalog/tests/test_pep8.py (+1/-1)
To merge this branch: bzr merge lp://staging/~elachuni/ubuntu-webcatalog/released-by-default
Reviewer Review Type Date Requested Status
Michael Nelson (community) Approve
Review via email: mp+121954@code.staging.launchpad.net

Commit message

Consider prereleased distroseries when displaying app data and calculating is_latest.

Description of the change

At some point the 'prerelease' bit was added onto a distroseries. At that point I thought we had made prerelease versions of apps not show up by default, but I seem to be wrong (or the code might have been rolled back at some point?)

Related bug #1042928 asks for this again: The data an application should display by default, when no distroseries is specified, should be the latest *released* version, if there is any released version available. If there is no released version, then it's fine to display the prerelease data.

While I was there, I made the pep8 test fail when it finds an issue, as it seems it was just displaying the error but not failing the test.

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :
Download full text (12.4 KiB)

On Wed, Aug 29, 2012 at 11:56 PM, Anthony Lenton
<email address hidden> wrote:
> For more details, see:
> https://code.launchpad.net/~elachuni/ubuntu-webcatalog/released-by-default/+merge/121954
>
> At some point the 'prerelease' bit was added onto a distroseries. At that point I thought we had made prerelease versions of apps not
> show up by default, but I seem to be wrong (or the code might have been rolled back at some point?)

That sounds bad - have you checked?

>
> Related bug #1042928 asks for this again: The data an application should display by default, when no distroseries is specified, should
> be the latest *released* version, if there is any released version available. If there is no released version, then it's fine to display the
> prerelease data.
>
> While I was there, I made the pep8 test fail when it finds an issue, as it seems it was just displaying the error but not failing the test.
> --
> https://code.launchpad.net/~elachuni/ubuntu-webcatalog/released-by-default/+merge/121954
> You are subscribed to branch lp:ubuntu-webcatalog.
>
> === modified file 'src/webcatalog/management/commands/check_all_latest.py'
> --- src/webcatalog/management/commands/check_all_latest.py 2012-06-06 16:38:11 +0000
> +++ src/webcatalog/management/commands/check_all_latest.py 2012-08-29 21:55:21 +0000
> @@ -48,17 +48,35 @@
> Application.objects.all().update(is_latest=False)
>
> # 2. Update is_latest in batches of BATCH_SIZE.
> - packages = Application.objects.values_list('id', 'package_name')
> + packages = Application.objects.values_list(
> + 'id', 'package_name', 'distroseries__prerelease')
> packages = packages.order_by('package_name', '-distroseries__version')
> current_package_name = None
> to_update = []
> - for app_id, app_package_name in packages:
> + prereleased = None # Store a prerelease app id here until we find
> + # a released version or run out of versions
> + for app_id, app_package_name, prerelease in packages:
> if current_package_name != app_package_name:
> - to_update.append(app_id)
> - if len(to_update) >= BATCH_SIZE:
> - Application.objects.filter(id__in=to_update).update(
> - is_latest=True)
> - to_update = []
> + is_latest = True
> current_package_name = app_package_name
> + if prereleased:
> + # If prereleased != None at this point, it's because the
> + # immediately previous app *only* has prerelease versions

Ah right, so a pre-release can have is_latest=True if there aren't any
other versions. Got it.
I got confused with prerelease vs prereleased... I wonder if
s/prereleased/prereleased_app_id/ might be worthwhile.

> + to_update.append(prereleased)
> + prereleased = None
> + if is_latest:
> + if prerelease:
> + if prereleased is None:
> + prereleased = app_id
> + else:
> + ...

Revision history for this message
Michael Nelson (michael.nelson) :
review: Approve
172. By Anthony Lenton

Refactored check_all_latest and dried up code a bit, per code review.

173. By Anthony Lenton

Minor refactor to find_best.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches