Fix bug when annotations are added in the metadataplayer
authorverrierj
Fri, 27 Jan 2012 16:16:54 +0100
changeset 478 260f3438cb78
parent 477 1c4894a4de72
child 479 1cbfcfcb2a47
Fix bug when annotations are added in the metadataplayer
src/ldt/ldt/api/ldt/handlers.py
src/ldt/ldt/ldt_utils/stat.py
--- a/src/ldt/ldt/api/ldt/handlers.py	Fri Jan 27 15:57:14 2012 +0100
+++ b/src/ldt/ldt/api/ldt/handlers.py	Fri Jan 27 16:16:54 2012 +0100
@@ -175,7 +175,7 @@
                 
                                 
                 content = project.contents.get(iri_id=a['media'])
-                add_annotation_to_stat(content, project, a['begin'], a['end'])
+                add_annotation_to_stat(content, a['begin'], a['end'])
                 
                 # We update the ids
                 a['type'] = type_id
--- a/src/ldt/ldt/ldt_utils/stat.py	Fri Jan 27 15:57:14 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/stat.py	Fri Jan 27 16:16:54 2012 +0100
@@ -52,12 +52,16 @@
     
 
 def add_annotation_to_stat(content, begin, end):
-    
+    nb_division = settings.DIVISIONS_FOR_STAT_ANNOTATION
+
     if not content.nb_annotation or not content.stat_annotation:
         content.nb_annotation = 1
         content.stat_annotation = get_empty_stat_vector()
     
-    buckets = find_buckets(content.stat_annotation, begin, end)
+    size_division = content.duration / nb_division
+    limits = [x * size_division for x in range(nb_division+1)]    
+    
+    buckets = find_buckets(content.annotation_volume, limits, begin, end)
     content.annotation_volume = buckets
     content.last_annotated = datetime.datetime.now()