summaryrefslogtreecommitdiff
path: root/meetingtools/apps
diff options
context:
space:
mode:
authorJohan Lundberg <lundberg@nordu.net>2014-04-04 11:19:37 +0200
committerJohan Lundberg <lundberg@nordu.net>2014-04-04 11:19:37 +0200
commit91395c1cbcc9b459206a9a651fd619feb5ef756b (patch)
tree24ce076969db00e722cc6079a6eed5fd0c96598e /meetingtools/apps
parentbcf7df5860a4d5648bc05b53ef5adef3084f952f (diff)
Full import now imports half a year at the time.
Diffstat (limited to 'meetingtools/apps')
-rw-r--r--meetingtools/apps/content/tasks.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/meetingtools/apps/content/tasks.py b/meetingtools/apps/content/tasks.py
index f7eb1c4..ba0940e 100644
--- a/meetingtools/apps/content/tasks.py
+++ b/meetingtools/apps/content/tasks.py
@@ -25,7 +25,7 @@ def import_acc(acc, since=0):
for row in r.et.xpath("//row"):
Content.create(acc, api, row)
nr += 1
- logging.info("%s: Imported %d objects." % (acc, nr))
+ logging.info("%s: Imported %d content objects." % (acc, nr))
@periodic_task(run_every=crontab(hour="*", minute="*/15", day_of_week="*"))
@@ -37,29 +37,32 @@ def import_all_content():
#@periodic_task(run_every=crontab(hour="1", minute="0", day_of_week="*"))
def timed_full_import():
years = [2009, 2010, 2011, 2012, 2013, 2014]
+ months = [(1, 7), (8, 12)] # Ugly hack as June does not have 31 days
for acc in ACCluster.objects.all():
nr = 0
for year in years:
- begin = datetime(year=year, month=1, day=1)
- end = datetime(year=year, month=12, day=31)
- with ac_api_client(acc) as api:
- try:
- r = api.request('report-bulk-objects',
- {'filter-out-type': 'meeting',
- 'filter-gte-date-modified': begin.isoformat(),
- 'filter-lte-date-modified': end.isoformat()},
- raise_error=True)
- if r:
- nr = 0
- for row in r.et.xpath("//row"):
- Content.create(acc, api, row)
- nr += 1
- except ACPException as e:
- logging.error('ACPException in content.timed_full_import')
- logging.error(e)
- pass
- except Exception as e:
- logging.error('Exception in content.timed_full_import')
- logging.error(e)
- pass
- logging.info("%s: Imported %d objects." % (acc, nr)) \ No newline at end of file
+ for month in months:
+ begin = datetime(year=year, month=month[0], day=1)
+ end = datetime(year=year, month=month[1], day=31)
+ with ac_api_client(acc) as api:
+ try:
+ r = api.request('report-bulk-objects',
+ {'filter-out-type': 'meeting',
+ 'filter-gte-date-modified': begin.isoformat(),
+ 'filter-lte-date-modified': end.isoformat()},
+ raise_error=True)
+ if r:
+ nr = 0
+ for row in r.et.xpath("//row"):
+ Content.create(acc, api, row)
+ nr += 1
+ except ACPException as e:
+ logging.error('ACPException in content.timed_full_import')
+ logging.error('Period %s %s-%s failed for cluster %s.' % (year, month[0], month[1], acc))
+ logging.error(e)
+ pass
+ except Exception as e:
+ logging.error('Exception in content.timed_full_import')
+ logging.error(e)
+ pass
+ logging.info("%s: Imported %d content objects." % (acc, nr)) \ No newline at end of file