Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add background task to import Durham data nightly #120

Merged
merged 1 commit into from
May 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions eatsmart/locations/durham/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from logging import getLogger

from eatsmart.celery import app
from eatsmart.locations.durham import api


logger = getLogger(__file__)


@app.task
def import_durham_data():
"""Import Durham data"""
logger.info("Starting Durham Import")
api.EstablishmentImporter().run()
api.InspectionImporter().run()
api.ViolationImporter().run()
logger.info("Finished Durham Import")
9 changes: 9 additions & 0 deletions eatsmart/settings/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Django settings for eatsmart project.
import os
from celery.schedules import crontab


PROJECT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
PROJECT_ROOT = os.path.abspath(os.path.join(PROJECT_PATH, os.pardir))
Expand Down Expand Up @@ -222,3 +224,10 @@
# Default user location
LATITUDE = 35.988611
LONGITUDE = -78.907222

CELERYBEAT_SCHEDULE = {
'import-durham-data': {
'task': 'eatsmart.locations.durham.tasks.import_durham_data',
'schedule': crontab(minute=0, hour=0), # Execute daily at midnight
},
}