Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/358419 )
Change subject: Update transactions for django 1.6+ ...................................................................... Update transactions for django 1.6+ Examples online show setting autocommit back to true at the end of functions, but it looks like we actually want it off everywhere we write to a db. Change-Id: Ic35fdc2013e108fbac10123f03cd720381d99f58 --- M fundraiser/analytics/management/commands/AggregateBannerImpressions.py M fundraiser/analytics/management/commands/LoadBannerImpressions.py M fundraiser/analytics/management/commands/LoadBannerImpressions2Aggregate.py M fundraiser/analytics/management/commands/LoadLPImpressions.py 4 files changed, 5 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/tools/DjangoBannerStats refs/changes/19/358419/1 diff --git a/fundraiser/analytics/management/commands/AggregateBannerImpressions.py b/fundraiser/analytics/management/commands/AggregateBannerImpressions.py index 8edb4a6..57b4d62 100644 --- a/fundraiser/analytics/management/commands/AggregateBannerImpressions.py +++ b/fundraiser/analytics/management/commands/AggregateBannerImpressions.py @@ -80,8 +80,8 @@ print "Aggregated %d rounds of %d each in %d.%d seconds" % (rounds, batch, (endtime - starttime).seconds, (endtime - starttime).microseconds) - @transaction.commit_manually def run(self, batchSize=1000): + transaction.set_autocommit(False) if not isinstance(batchSize, int): raise TypeError("Invalid batch size %s" % batchSize) diff --git a/fundraiser/analytics/management/commands/LoadBannerImpressions.py b/fundraiser/analytics/management/commands/LoadBannerImpressions.py index fa92580..fd3dbc8 100644 --- a/fundraiser/analytics/management/commands/LoadBannerImpressions.py +++ b/fundraiser/analytics/management/commands/LoadBannerImpressions.py @@ -444,13 +444,13 @@ return results - @transaction.commit_manually def write(self, impressions): """ Commits a batch of transactions. Attempts a single query per model by splitting the tuples of each banner impression and grouping by model. If that fails, the function falls back to a single transaction per banner impression """ + transaction.set_autocommit(False) cursor = connections['default'].cursor() i_len = len(impressions) @@ -491,13 +491,13 @@ for i in impressions: self.write([i]) - @transaction.commit_manually def write_hidden(self, impressions): """ Commits a batch of transactions. Attempts a single query per model by splitting the tuples of each banner impression and grouping by model. If that fails, the function falls back to a single transaction per banner impression """ + transaction.set_autocommit(False) cursor = connections['default'].cursor() i_len = len(impressions) diff --git a/fundraiser/analytics/management/commands/LoadBannerImpressions2Aggregate.py b/fundraiser/analytics/management/commands/LoadBannerImpressions2Aggregate.py index ee83ede..3b67b04 100644 --- a/fundraiser/analytics/management/commands/LoadBannerImpressions2Aggregate.py +++ b/fundraiser/analytics/management/commands/LoadBannerImpressions2Aggregate.py @@ -389,9 +389,8 @@ return results - @transaction.commit_manually def write(self, impressions): - + transaction.set_autocommit(False) insert_sql = "INSERT INTO bannerimpressions (timestamp, banner, campaign, project_id, language_id, country_id, count) VALUES (%s) ON DUPLICATE KEY update count=count+%d" cursor = connections['default'].cursor() diff --git a/fundraiser/analytics/management/commands/LoadLPImpressions.py b/fundraiser/analytics/management/commands/LoadLPImpressions.py index 3ee30d6..710171f 100644 --- a/fundraiser/analytics/management/commands/LoadLPImpressions.py +++ b/fundraiser/analytics/management/commands/LoadLPImpressions.py @@ -442,13 +442,13 @@ return results - @transaction.commit_manually def write(self, base_sql, impressions): """ Commits a batch of transactions. Attempts a single query per model by splitting the tuples of each banner impression and grouping by model. If that fails, the function falls back to a single transaction per banner impression """ + transaction.set_autocommit(False) i_len = len(impressions) if not i_len: -- To view, visit https://gerrit.wikimedia.org/r/358419 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic35fdc2013e108fbac10123f03cd720381d99f58 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/tools/DjangoBannerStats Gerrit-Branch: master Gerrit-Owner: Ejegg <ej...@ejegg.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits