Skip to content

Commit

Permalink
Fix #54: Add an aggregates task
Browse files Browse the repository at this point in the history
  • Loading branch information
kmtracey committed Jul 31, 2012
1 parent 58f6ddc commit dd70697
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,3 +10,4 @@ shapefiles/
openrural/settings/local.py
*.DS_Store
.vagrant
*.swp
Empty file.
3 changes: 3 additions & 0 deletions openrural/periodic_tasks/models.py
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
18 changes: 18 additions & 0 deletions openrural/periodic_tasks/tasks.py
@@ -0,0 +1,18 @@
from celery.task import Task, PeriodicTask
from celery.registry import tasks
from datetime import timedelta

from ebpub.db.bin.update_aggregates import update_all_aggregates

class AggregatesTask(PeriodicTask):

name = 'openrural.aggregates'
run_every = timedelta(hours=12)

def run(self, dry_run=False, reset=False):
logger = self.get_logger()
logger.info("Starting aggregates task")
update_all_aggregates(dry_run, reset)
logger.info("Stopping aggregates task")

tasks.register(AggregatesTask)
1 change: 1 addition & 0 deletions openrural/settings/base.py
Expand Up @@ -35,6 +35,7 @@
'openrural',
'gunicorn',
'openrural.data_dashboard',
'openrural.periodic_tasks',
'django.contrib.messages',
) + INSTALLED_APPS
TEMPLATE_DIRS = (os.path.join(PROJECT_DIR, 'templates'), ) + TEMPLATE_DIRS
Expand Down

0 comments on commit dd70697

Please sign in to comment.