summaryrefslogtreecommitdiff
path: root/meetingtools/apps/stats/tasks.py
diff options
context:
space:
mode:
Diffstat (limited to 'meetingtools/apps/stats/tasks.py')
-rw-r--r--meetingtools/apps/stats/tasks.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/meetingtools/apps/stats/tasks.py b/meetingtools/apps/stats/tasks.py
index 49e9abd..0a26d66 100644
--- a/meetingtools/apps/stats/tasks.py
+++ b/meetingtools/apps/stats/tasks.py
@@ -54,5 +54,29 @@ def _hourly_import():
#@periodic_task(run_every=crontab(hour="5", minute="0", day_of_week="*"))
def timed_full_import():
+ years = [2009, 2010, 2011, 2012, 2013, 2014]
for acc in ACCluster.objects.all():
- import_acc_sessions(acc, room_last_visited=True) \ No newline at end of file
+ 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:
+ p = {'sort': 'asc', 'sort1': 'date-created', 'filter-type': 'meeting',
+ 'filter-gte-date-created': begin.isoformat(), 'filter-lte-date-created': end.isoformat()}
+ r = api.request('report-bulk-consolidated-transactions', p, True)
+ nr = 0
+ ne = 0
+ for tx in r.et.findall(".//row"):
+ try:
+ tx = UserMeetingTransaction.create(acc, tx)
+ if tx:
+ rooms = Room.objects.filter(sco=tx.sco)
+ if len(rooms) == 1:
+ room = rooms[0]
+ if room.lastvisited is None or room.lastvisited < tx.date_closed:
+ room.lastvisited = tx.date_created
+ room.save()
+ nr += 1
+ except Exception, ex:
+ logging.error(ex)
+ ne += 1
+ logging.info("%s: Imported %d transactions with %d errors" % (acc, nr, ne)) \ No newline at end of file