GitHub PullRequestReviewCommentEvent at 2014-06-02 17:14:09
Repository: socorro
Actor: rhelmer
Payload: {"comment":{"url":"https://api.github.com/repos/mozilla/socorro/pulls/comments/13295746","id":13295746,"diff_hunk":"@@ -0,0 +1,41 @@\n+# This Source Code Form is subject to the terms of the Mozilla Public\n+# License, v. 2.0. If a copy of the MPL was not distributed with this\n+# file, You can obtain one at http://mozilla.org/MPL/2.0/.\n+\n+# crontabber\n+from crontabber.base import BaseCronApp\n+from crontabber.mixins import (\n+    with_postgres_transactions,\n+    with_single_postgres_transaction,\n+)\n+# this job\n+from datetime import datetime, timedelta\n+from dateutil.relativedelta import relativedelta\n+\n+@with_postgres_transactions()\n+@with_single_postgres_transaction()\n+class DropOldPartitionsCronApp(BaseCronApp):\n+    app_name = 'drop-old-partitions'\n+    app_version = '1.0'\n+    app_description = \"\"\"See\n+    http://socorro.readthedocs.org/en/latest/databaseadminfunctions.html#drop\n+    -old-partitions\n+    See https://bugzilla.mozilla.org/show_bug.cgi?id=1014128\n+    \"\"\"\n+\n+    def run(self, connection):\n+        # Determine date from one year ago.\n+        one_year_ago = datetime.now() - relativedelta(years=1)\n+\n+        # Determine delta between previous Monday and year-old-date.\n+        delta_previous_monday = 0 - one_year_ago.weekday()\n+\n+        # Determine date of Monday preceeding year-old-date.\n+        # This is an add operation but of a negative value, so subtraction.\n+        year_old_monday = one_year_ago + timedelta(days=delta_previous_monday)\n+","path":"socorro/cron/jobs/drop_old_partitions.py","position":36,"original_position":36,"commit_id":"64031cf38ae84cef12c277556854400faf7b6769","original_commit_id":"64031cf38ae84cef12c277556854400faf7b6769","user":{"login":"rhelmer","id":61412,"avatar_url":"https://avatars.githubusercontent.com/u/61412?","gravatar_id":"aedfcfd22f63c0f0a6b3ce6b9024df9e","url":"https://api.github.com/users/rhelmer","html_url":"https://github.com/rhelmer","followers_url":"https://api.github.com/users/rhelmer/followers","following_url":"https://api.github.com/users/rhelmer/following{/other_user}","gists_url":"https://api.github.com/users/rhelmer/gists{/gist_id}","starred_url":"https://api.github.com/users/rhelmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhelmer/subscriptions","organizations_url":"https://api.github.com/users/rhelmer/orgs","repos_url":"https://api.github.com/users/rhelmer/repos","events_url":"https://api.github.com/users/rhelmer/events{/privacy}","received_events_url":"https://api.github.com/users/rhelmer/received_events","type":"User","site_admin":false},"body":"Just a nit because this code works fine but I find it a little confusing (comments help here :+1: ) - ```dateutil.relativedelta``` has weekday instances, this might read a little better if you use ```MO``` to get the previous Monday. ","created_at":"2014-06-02T17:14:09Z","updated_at":"2014-06-02T17:14:09Z","html_url":"https://github.com/mozilla/socorro/pull/2070#discussion_r13295746","pull_request_url":"https://api.github.com/repos/mozilla/socorro/pulls/2070","_links":{"self":{"href":"https://api.github.com/repos/mozilla/socorro/pulls/comments/13295746"},"html":{"href":"https://github.com/mozilla/socorro/pull/2070#discussion_r13295746"},"pull_request":{"href":"https://api.github.com/repos/mozilla/socorro/pulls/2070"}}}}