#-*- coding:utf-8 -*- import datetime from collections import Counter from django.core.management.base import BaseCommand from dictionary.models import get_checked_statuses, get_ready_statuses from dictionary.ajax_vocabulary_management import get_stats, write_stats class Command(BaseCommand): help = 'Get Walenty statistics.' def handle(self, **options): now = datetime.datetime.now().strftime('%Y%m%d') all_statuses = get_ready_statuses() verified_statuses = get_checked_statuses() nouns_stats_dict_all = Counter(get_stats(all_statuses, 'noun')) write_stats('data/stats_%s_nouns_all.txt' % now, nouns_stats_dict_all) nouns_stats_dict_verified = Counter(get_stats(verified_statuses, 'noun')) write_stats('data/stats_%s_nouns_verified.txt' % now, nouns_stats_dict_verified) adjs_stats_dict_all = Counter(get_stats(all_statuses, 'adj')) write_stats('data/stats_%s_adjs_all.txt' % now, adjs_stats_dict_all) adjs_stats_dict_verified = Counter(get_stats(verified_statuses, 'adj')) write_stats('data/stats_%s_adjs_verified.txt' % now, adjs_stats_dict_verified) verbs_stats_dict_all = Counter(get_stats(all_statuses, 'verb')) write_stats('data/stats_%s_verbs_all.txt' % now, verbs_stats_dict_all) verbs_stats_dict_verified = Counter(get_stats(verified_statuses, 'verb')) write_stats('data/stats_%s_verbs_verified.txt' % now, verbs_stats_dict_verified) advs_stats_dict_all = Counter(get_stats(all_statuses, 'adv')) write_stats('data/stats_%s_advs_all.txt' % now, advs_stats_dict_all) advs_stats_dict_verified = Counter(get_stats(verified_statuses, 'adv')) write_stats('data/stats_%s_advs_verified.txt' % now, advs_stats_dict_verified) all_stats_dict_all = nouns_stats_dict_all + adjs_stats_dict_all + verbs_stats_dict_all + advs_stats_dict_all all_stats_dict_verified = nouns_stats_dict_verified + adjs_stats_dict_verified + verbs_stats_dict_verified + advs_stats_dict_verified write_stats('data/stats_%s_all.txt' % now, all_stats_dict_all) write_stats('data/stats_%s_verified.txt' % now, all_stats_dict_verified)