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
=== modified file 'src/oopstools/oops/dboopsloader.py'
--- src/oopstools/oops/dboopsloader.py 2011-10-13 20:18:51 +0000
+++ src/oopstools/oops/dboopsloader.py 2011-10-21 15:18:26 +0000
@@ -151,10 +151,12 @@
151 oops = self._load_oops(datedir, filename)151 oops = self._load_oops(datedir, filename)
152 if oops is not None:152 if oops is not None:
153 yield oops153 yield oops
154 # We do this every time because scripts that use154 # We update the last_date only when oops
155 # it (update_db.py) might stop after any oops.155 # has the date different to what we already have
156 entry.last_date = date156 # This speeds up the loading process
157 entry.save()157 if entry.last_date != date:
158 entry.last_date = date
159 entry.save()
158 date += datetime.timedelta(days=1)160 date += datetime.timedelta(days=1)
159161
160 def _load_oops(self, datedir, filename):162 def _load_oops(self, datedir, filename):

Subscribers

People subscribed via source and target branches

to all changes: