diff -r af360d447874 -r a1e9f5e91791 src/ldt/ldt/management/commands/statannotation.py --- a/src/ldt/ldt/management/commands/statannotation.py Thu Jan 26 15:04:38 2012 +0100 +++ b/src/ldt/ldt/management/commands/statannotation.py Thu Jan 26 16:01:12 2012 +0100 @@ -1,23 +1,22 @@ +from django.conf import settings from django.core.management.base import BaseCommand -from ldt.ldt_utils.models import Content, Project -from ldt.ldt_utils.stat import update_stat_content, update_stat_project +from ldt.ldt_utils.models import Content +from ldt.ldt_utils.stat import update_stat_content, get_empty_stat_vector class Command(BaseCommand): - help = 'Computes annotation for all contents and all projects' + help = 'Computes annotation for all contents' def handle(self, *args, **options): - for proj in Project.objects.all(): - print "Stat for project %s" % proj - update_stat_project(proj) - - # Sets fields nb_annotation and stat_annotation to 0 and 0,0,...,0 - # for contents that do not have annotations - for content in Content.objects.all(): - if not content.stat_annotation: - print "Stat for content %s" % content - update_stat_content(content) + size_stat = len(get_empty_stat_vector()) + + for c in Content.objects.all(): + if len( c.stat_annotation.split(',')) != size_stat: + c.stat_annotation = [0] * size_stat + c.save() + + update_stat_content(c) return None \ No newline at end of file