Skip to content

Instantly share code, notes, and snippets.

@rhelmer
Created May 16, 2012 21:36
Show Gist options
  • Select an option

  • Save rhelmer/2714135 to your computer and use it in GitHub Desktop.

Select an option

Save rhelmer/2714135 to your computer and use it in GitHub Desktop.
diff --git a/config/crontabber.ini b/config/crontabber.ini
index 3421e42..72c2ed9 100644
--- a/config/crontabber.ini
+++ b/config/crontabber.ini
@@ -14,7 +14,9 @@ database_class=socorro.external.postgresql.connection_context.ConnectionContext
# name: jobs
# doc: None
# converter: class_list_converter
-jobs='''socorro.cron.jobs.weekly_reports_partitions.WeeklyReportsPartitionsCronApp|7d'''
+jobs='''socorro.cron.jobs.weekly_reports_partitions.WeeklyReportsPartitionsCronApp|7d
+ socorro.cron.jobs.nightly_builds.NightlyBuildsCronApp|1d
+'''
# name: stderr_error_logging_level
# doc: logging level for the logging to stderr (10 - DEBUG, 20 - INFO, 30 - WARNING, 40 - ERROR, 50 - CRITICAL)
diff --git a/socorro/cron/jobs/nightly_builds.py b/socorro/cron/jobs/nightly_builds.py
new file mode 100644
index 0000000..a0fe0fa
--- /dev/null
+++ b/socorro/cron/jobs/nightly_builds.py
@@ -0,0 +1,15 @@
+from configman import Namespace
+from socorro.cron.crontabber import PostgresCronApp
+
+
+class NightlyBuildsCronApp(PostgresCronApp):
+ app_name = 'nightly_builds'
+ app_description = """Populate nightly_builds table.
+ See https://bugzilla.mozilla.org/show_bug.cgi?id=751298
+ """
+
+ required_config = Namespace()
+
+ def run(self, connection):
+ cursor = connection.cursor()
+ cursor.callproc('update_nightly_builds', 'CURRENT_DATE')
diff --git a/socorro/cron/jobs/weekly_reports_partitions.py b/socorro/cron/jobs/weekly_reports_partitions.py
index 082c306..e3d6877 100644
--- a/socorro/cron/jobs/weekly_reports_partitions.py
+++ b/socorro/cron/jobs/weekly_reports_partitions.py
@@ -1,8 +1,8 @@
from configman import Namespace
-from socorro.cron.crontabber import PostgreSQLCronApp
+from socorro.cron.crontabber import PostgresCronApp
-class WeeklyReportsPartitionsCronApp(PostgreSQLCronApp):
+class WeeklyReportsPartitionsCronApp(PostgresCronApp):
app_name = 'weekly-reports-partitions'
app_description = """See
http://socorro.readthedocs.org/en/latest/databaseadminfunctions.html#weekly
@@ -14,4 +14,4 @@ class WeeklyReportsPartitionsCronApp(PostgreSQLCronApp):
def run(self, connection):
cursor = connection.cursor()
- cursor.execute('SELECT weekly_report_partitions()')
+ cursor.callproc('weekly_report_partitions')
@rhelmer
Copy link
Author

rhelmer commented May 16, 2012

diff --git a/config/crontabber.ini b/config/crontabber.ini
index 3421e42..72c2ed9 100644
--- a/config/crontabber.ini
+++ b/config/crontabber.ini
@@ -14,7 +14,9 @@ database_class=socorro.external.postgresql.connection_context.ConnectionContext

name: jobs

doc: None

converter: class_list_converter

-jobs='''socorro.cron.jobs.weekly_reports_partitions.WeeklyReportsPartitionsCronApp|7d'''
+jobs='''socorro.cron.jobs.weekly_reports_partitions.WeeklyReportsPartitionsCronApp|7d

  •    socorro.cron.jobs.nightly_builds.NightlyBuildsCronApp|1d
    

    +'''

    name: stderr_error_logging_level

    doc: logging level for the logging to stderr (10 - DEBUG, 20 - INFO, 30 - WARNING, 40 - ERROR, 50 - CRITICAL)

    diff --git a/socorro/cron/jobs/nightly_builds.py b/socorro/cron/jobs/nightly_builds.py
    new file mode 100644
    index 0000000..a1b60ee
    --- /dev/null
    +++ b/socorro/cron/jobs/nightly_builds.py
    @@ -0,0 +1,15 @@
    +from configman import Namespace
    +from socorro.cron.crontabber import PostgresCronApp
    +
    +
    +class NightlyBuildsCronApp(PostgresCronApp):

  • app_name = 'nightly_builds'

  • app_description = """Populate nightly_builds table.

  • See https://bugzilla.mozilla.org/show_bug.cgi?id=751298

  • """

  • required_config = Namespace()
  • def run(self, connection):
  •    cursor = connection.cursor()
    
  •    cursor.callproc('update_nightly_builds', ['now'])
    
    diff --git a/socorro/cron/jobs/weekly_reports_partitions.py b/socorro/cron/jobs/weekly_reports_partitions.py
    index 082c306..e3d6877 100644
    --- a/socorro/cron/jobs/weekly_reports_partitions.py
    +++ b/socorro/cron/jobs/weekly_reports_partitions.py
    @@ -1,8 +1,8 @@
    from configman import Namespace
    -from socorro.cron.crontabber import PostgreSQLCronApp
    +from socorro.cron.crontabber import PostgresCronApp

-class WeeklyReportsPartitionsCronApp(PostgreSQLCronApp):
+class WeeklyReportsPartitionsCronApp(PostgresCronApp):
app_name = 'weekly-reports-partitions'
app_description = """See
http://socorro.readthedocs.org/en/latest/databaseadminfunctions.html#weekly
@@ -14,4 +14,4 @@ class WeeklyReportsPartitionsCronApp(PostgreSQLCronApp):

 def run(self, connection):
     cursor = connection.cursor()
  •    cursor.execute('SELECT weekly_report_partitions()')
    
  •    cursor.callproc('weekly_report_partitions')
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment