Skip to content

Commit

Permalink
bug777670 - commit the transaction on matviews, r=rhelmer
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored and rhelmer committed Jul 28, 2012
1 parent 02e3193 commit d964d48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions socorro/cron/jobs/matviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class _MatViewBase(PostgresCronApp, _Base):
def run(self, connection):
cursor = connection.cursor()
cursor.callproc(self.get_proc_name())
connection.commit()


class _MatViewBackfillBase(PostgresBackfillCronApp, _Base):
Expand All @@ -29,6 +30,7 @@ def run(self, connection, date):
cursor = connection.cursor()
target_date = (date - datetime.timedelta(days=1)).date()
cursor.callproc(self.get_proc_name(), [target_date])
connection.commit()

#------------------------------------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions socorro/unittest/cron/jobs/test_matviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ def test_all_matviews(self):
# e.g. ('update_signatures', [datetime.date(2012, 6, 25)])
# then check that it's a datetime.date instance
self.assertTrue(isinstance(call_args[1][0], datetime.date))
# the reason we expect 9 * 2 commit() calls is because,
# for each job it commits the actual run and it also commits
# when it writes to the JSON database
self.assertEqual(self.psycopg2().commit.call_count, 9 * 2)

0 comments on commit d964d48

Please sign in to comment.