Fix bug in regenerating stat command
authorverrierj
Fri, 27 Jan 2012 15:26:57 +0100
changeset 474 5e7942f049a6
parent 473 a400c401f78b
child 475 fb7d796d52a7
Fix bug in regenerating stat command
src/ldt/ldt/ldt_utils/stat.py
src/ldt/ldt/management/commands/statannotation.py
--- a/src/ldt/ldt/ldt_utils/stat.py	Fri Jan 27 15:18:36 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/stat.py	Fri Jan 27 15:26:57 2012 +0100
@@ -76,6 +76,8 @@
 def get_empty_stat_vector():
     return [0] * (settings.DIVISIONS_FOR_STAT_ANNOTATION + 4) # + 4 for polemic syntax
 
+def get_empty_stat_field():
+    return ("%s" % get_empty_stat_vector())[1:-1].replace(' ', '')
 
 def find_buckets(buckets, limits, begin, end):
     
--- a/src/ldt/ldt/management/commands/statannotation.py	Fri Jan 27 15:18:36 2012 +0100
+++ b/src/ldt/ldt/management/commands/statannotation.py	Fri Jan 27 15:26:57 2012 +0100
@@ -1,6 +1,6 @@
 from django.core.management.base import BaseCommand
 from ldt.ldt_utils.models import Content
-from ldt.ldt_utils.stat import update_stat_content, get_empty_stat_vector
+from ldt.ldt_utils.stat import update_stat_content, get_empty_stat_vector, get_empty_stat_field
 
 class Command(BaseCommand):
     help = 'Computes annotation for all contents'
@@ -13,7 +13,7 @@
        
         for c in Content.objects.all():
             if not c.stat_annotation or len( c.stat_annotation.split(',')) != size_stat:
-                c.stat_annotation = c.list2str(empty_stat_vector)
+                c.stat_annotation = get_empty_stat_field()
                 c.save()
             
             update_stat_content(c)