def activity_logs_for_user(user,action=None,days_ago=None): from jv3.study.content_analysis import _actlogs_to_values,_notes_to_values if days_ago is None: #print "days ago is none" if action: return _actlogs_to_values(ActivityLog.objects.filter(action=action,owner=user).order_by("when")) return _actlogs_to_values(ActivityLog.objects.filter(owner=user).order_by("when")) else: today_msec = current_time_decimal() n_days_ago = today_msec - days_ago*24*60*60*1000 print "starting with %d // %s" % (n_days_ago,repr(datetime.datetime.fromtimestamp(n_days_ago/1000.0))) if action: return _actlogs_to_values(ActivityLog.objects.filter(action=action,owner=user,when__gt=n_days_ago)) return _actlogs_to_values(ActivityLog.objects.filter(owner=user,when__gt=n_days_ago))
def _prime_actlog_cache(notevals): #print [ "_priming : %s -> %s____" % (noteval["id"],noteval["jid"]) for noteval in notevals ] global _activity_log_cache_by_note from jv3.study.content_analysis import _actlogs_to_values,_notes_to_values ## convert jid -> id _activity_log_cache_by_note.update( dict([ (n["id"],[]) for n in notevals ])) for av in _actlogs_to_values(ActivityLog.objects.filter(noteid__in=[n["jid"] for n in notevals])): nid = [n for n in notevals if n["jid"] == av["noteid"]][0]["id"] _activity_log_cache_by_note[nid] = _activity_log_cache_by_note.get( nid , [] ) + [ av ]
def _prime_actlog_cache(notevals): #print [ "_priming : %s -> %s____" % (noteval["id"],noteval["jid"]) for noteval in notevals ] global _activity_log_cache_by_note from jv3.study.content_analysis import _actlogs_to_values, _notes_to_values ## convert jid -> id _activity_log_cache_by_note.update(dict([(n["id"], []) for n in notevals])) for av in _actlogs_to_values( ActivityLog.objects.filter(noteid__in=[n["jid"] for n in notevals])): nid = [n for n in notevals if n["jid"] == av["noteid"]][0]["id"] _activity_log_cache_by_note[nid] = _activity_log_cache_by_note.get( nid, []) + [av]
def activity_logs_for_user(user, action=None, days_ago=None): from jv3.study.content_analysis import _actlogs_to_values, _notes_to_values if days_ago is None: #print "days ago is none" if action: return _actlogs_to_values( ActivityLog.objects.filter(action=action, owner=user).order_by("when")) return _actlogs_to_values( ActivityLog.objects.filter(owner=user).order_by("when")) else: today_msec = current_time_decimal() n_days_ago = today_msec - days_ago * 24 * 60 * 60 * 1000 print "starting with %d // %s" % ( n_days_ago, repr(datetime.datetime.fromtimestamp(n_days_ago / 1000.0))) if action: return _actlogs_to_values( ActivityLog.objects.filter(action=action, owner=user, when__gt=n_days_ago)) return _actlogs_to_values( ActivityLog.objects.filter(owner=user, when__gt=n_days_ago))