correct stat to work with non naive datetime
authorymh <ymh.work@gmail.com>
Sat, 09 Jun 2012 02:08:02 +0200
changeset 662 73b94f485ed2
parent 661 19eb49289005
child 663 0daa35bdb06b
correct stat to work with non naive datetime
src/ldt/ldt/ldt_utils/stat.py
--- a/src/ldt/ldt/ldt_utils/stat.py	Sat Jun 09 01:57:57 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/stat.py	Sat Jun 09 02:08:02 2012 +0200
@@ -1,6 +1,7 @@
 from django.conf import settings #@UnresolvedImport
 from ldt.ldt_utils.models import Segment, ContentStat, POL_INDICES
 import datetime
+import pytz
 
 def update_stat_content(content):
     
@@ -17,7 +18,8 @@
 
     pol_stats = [0]*len(POL_INDICES)
     
-    min_update_ts = datetime.datetime.min #@UndefinedVariable
+    min_ts = datetime.datetime.min.replace(tzinfo=pytz.utc)
+    min_update_ts = min_ts #@UndefinedVariable
     
     for segment in segments:
         
@@ -40,7 +42,7 @@
     contentstat.polemics_volume = pol_stats
     contentstat.annotation_volume = buckets
     contentstat.nb_annotations = nb_annotation
-    contentstat.last_annotated = min_update_ts if min_update_ts > datetime.datetime.min else content.update_date #@UndefinedVariable
+    contentstat.last_annotated = min_update_ts if min_update_ts > min_ts else content.update_date #@UndefinedVariable
     
     contentstat.save()