summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2012-02-06 14:05:24 +0100
committerLeif Johansson <leifj@sunet.se>2012-02-06 14:05:24 +0100
commit4b3351e3e37eec11285ae47163df70c669fd19ea (patch)
tree14d20f4178ad30af66bbd523fd04d843461fe3c6 /src
parent9d323e709650fd088dbe053044a203470b09175e (diff)
recheck all recently active rooms often
Diffstat (limited to 'src')
-rw-r--r--src/meetingtools/apps/room/tasks.py39
1 files changed, 8 insertions, 31 deletions
diff --git a/src/meetingtools/apps/room/tasks.py b/src/meetingtools/apps/room/tasks.py
index 63fb592..0d638a6 100644
--- a/src/meetingtools/apps/room/tasks.py
+++ b/src/meetingtools/apps/room/tasks.py
@@ -136,10 +136,11 @@ def import_all_rooms():
for acc in ACCluster.objects.all():
_import_acc(acc)
-def _import_meeting_room_session(api,acc,sco_id,row=None,room=None):
+def _import_meeting_room_usercount(api,acc,sco_id,row=None,room=None):
try:
if room == None:
room = Room.objects.get(acc=acc,sco_id=sco_id)
+
if row and row.findtext("date-end"):
room.user_count = 0
room.host_count = 0
@@ -155,38 +156,14 @@ def _import_meeting_room_session(api,acc,sco_id,row=None,room=None):
except ObjectDoesNotExist:
pass
-def _import_meeting_sessions_acc(acc):
+def _import_user_counts_acc(acc):
api = ac_api_client_direct(acc)
- backthen = datetime.now()-timedelta(seconds=600000)
- backthen = backthen.replace(microsecond=0)
- logging.debug(backthen.isoformat())
- r = api.request('report-meeting-sessions',{'filter-gt-date-created': backthen.isoformat()})
- seen = {}
- for row in r.et.xpath("//row"):
- try:
- sco_id = int(row.get('sco-id'))
- _import_meeting_room_session(api,acc,sco_id,row,None)
- seen[sco_id] = True
- except Exception,ex:
- logging.error(ex)
-
for room in Room.objects.filter(acc=acc,user_count=None):
- logging.debug("checking sessions on room: %s" % room)
- if seen.get(room.sco_id,False):
- continue
- try:
- logging.debug("importing sessions")
- _import_meeting_room_session(api,acc,room.sco_id,None,room)
- except Exception,ex:
- logging.error(ex)
-
-def _recheck_active_meetings_acc(acc):
- api = ac_api_client_direct(acc)
+ _import_meeting_room_usercount(api,acc,room.sco_id,None,room)
for room in Room.objects.filter(acc=acc,user_count__gt=0):
- _import_meeting_room_session(api,acc,room.sco_id,None,room)
-
+ _import_meeting_room_usercount(api,acc,room.sco_id,None,room)
+
@periodic_task(run_every=crontab(hour="*", minute="*/1", day_of_week="*"))
-def _import_meeting_sessions():
+def import_user_counts():
for acc in ACCluster.objects.all():
- _import_meeting_sessions_acc(acc)
- _recheck_active_meetings_acc(acc) \ No newline at end of file
+ _import_user_counts_acc(acc) \ No newline at end of file