Merge lp:~rye/python-oops-tools/oopsloader-update-date-when-needed into lp:python-oops-tools

Proposed by Roman Yepishev
Status: Merged
Approved by: Robert Collins
Approved revision: 5
Merged at revision: 5
Proposed branch: lp:~rye/python-oops-tools/oopsloader-update-date-when-needed
Merge into: lp:python-oops-tools
Diff against target: 20 lines (+6/-4)
1 file modified
src/oopstools/oops/dboopsloader.py (+6/-4)
To merge this branch: bzr merge lp:~rye/python-oops-tools/oopsloader-update-date-when-needed
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+80079@code.launchpad.net

Commit message

Tune dboopsloader to avoid pointless commits to the last-processed date marker.

Description of the change

Tune dboopsloader to avoid pointless commits to the last-processed date marker.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

.save does not do what you think it does :)

You need the .save, but what you want to avoid is the commits; that means:
 - taking the ORM out of autocommit mode
 - explicitly doing a commit (I suggest one every 5 seconds work)

review: Needs Fixing
Revision history for this message
Robert Collins (lifeless) wrote :

Oh bah, I see, I misread. So I'm going to +1 this instead, but I'll note that there is an equal performance win waiting if we move out of autocommit mode.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/oopstools/oops/dboopsloader.py'
2--- src/oopstools/oops/dboopsloader.py 2011-10-13 20:18:51 +0000
3+++ src/oopstools/oops/dboopsloader.py 2011-10-21 15:18:26 +0000
4@@ -151,10 +151,12 @@
5 oops = self._load_oops(datedir, filename)
6 if oops is not None:
7 yield oops
8- # We do this every time because scripts that use
9- # it (update_db.py) might stop after any oops.
10- entry.last_date = date
11- entry.save()
12+ # We update the last_date only when oops
13+ # has the date different to what we already have
14+ # This speeds up the loading process
15+ if entry.last_date != date:
16+ entry.last_date = date
17+ entry.save()
18 date += datetime.timedelta(days=1)
19
20 def _load_oops(self, datedir, filename):

Subscribers

People subscribed via source and target branches

to all changes: