Merge lp://staging/~dholbach/developer-ubuntu-com/queue-updates-1transaction into lp://staging/developer-ubuntu-com

Proposed by Daniel Holbach
Status: Merged
Approved by: David Callé
Approved revision: 140
Merged at revision: 145
Proposed branch: lp://staging/~dholbach/developer-ubuntu-com/queue-updates-1transaction
Merge into: lp://staging/developer-ubuntu-com
Diff against target: 184 lines (+51/-25)
1 file modified
developer_portal/management/commands/import-external-docs-branches.py (+51/-25)
To merge this branch: bzr merge lp://staging/~dholbach/developer-ubuntu-com/queue-updates-1transaction
Reviewer Review Type Date Requested Status
David Callé (community) Approve
Ubuntu App Developer site developers Pending
Review via email: mp+270158@code.staging.launchpad.net

Commit message

Queue create/update/remove transactions and run them in one transaction at the end.

This hopefully avoid writes in different developer.u.c app units.

Description of the change

Queue create/update/remove transactions and run them in one transaction at the end. This hopefully avoid writes in different developer.u.c app units.

Change logging.ERROR to logging.DEBUG to see DB queries.

To post a comment you must log in.
137. By Daniel Holbach

remove old Page.delete() statement

138. By Daniel Holbach

use db_actions.remove_page

139. By Daniel Holbach

merge trunk

Revision history for this message
Daniel Holbach (dholbach) wrote :

Test data to use:

sqlite> select * from developer_portal_externaldocsbranch;
1|lp:snapcraft|snappy/snapcraft|intro.md
2|lp:snappy|snappy/guides/devel|
3|lp:snappy/15.04|snappy/guides/current|
sqlite>

Revision history for this message
Daniel Holbach (dholbach) wrote :

Some more explanation of what's happening:

Add a DBAction class with three methods: add_page() and remove_page() to add actions to the queue and run() to execute the actions. The queue uses a list, so the order is preserved (not that it should matter in our case).

The Page.objects...delete() call is replaced with remove_page().
The get_or_create_page() calls are replaced with add_page() calls.

For convenience, the call to .publish('en') is also moved into DBAction.run().

The constructors of the individual classes are all modified to pass our DBAction queue to all the places where it's required.

Hope that makes the review easier.

140. By Daniel Holbach

apply fix from David for the case where there are no pages in the database yet

Revision history for this message
David Callé (davidc3) wrote :

+1!

review: Approve

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