Blame view

dictionary/management/commands/get_stats.py 2.21 KB
Bartłomiej Nitoń authored
1
2
#-*- coding:utf-8 -*-
Bartłomiej Nitoń authored
3
import datetime
Bartłomiej Nitoń authored
4
5
6
7
from collections import Counter

from django.core.management.base import BaseCommand
Bartłomiej Nitoń authored
8
9
from dictionary.models import get_checked_statuses, get_ready_statuses
from dictionary.ajax_vocabulary_management import get_stats, write_stats
Bartłomiej Nitoń authored
10
11

class Command(BaseCommand):
Bartłomiej Nitoń authored
12
    help = 'Get Walenty statistics.'
Bartłomiej Nitoń authored
13
14

    def handle(self, **options):
Bartłomiej Nitoń authored
15
16
17
        now = datetime.datetime.now().strftime('%Y%m%d')
        all_statuses = get_ready_statuses()
        verified_statuses = get_checked_statuses()
Bartłomiej Nitoń authored
18
Bartłomiej Nitoń authored
19
20
21
22
        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)
Bartłomiej Nitoń authored
23
Bartłomiej Nitoń authored
24
25
26
27
        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)
Bartłomiej Nitoń authored
28
Bartłomiej Nitoń authored
29
30
31
32
        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)
Bartłomiej Nitoń authored
33
Bartłomiej Nitoń authored
34
35
36
37
        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)
Bartłomiej Nitoń authored
38
Bartłomiej Nitoń authored
39
40
        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
Bartłomiej Nitoń authored
41
Bartłomiej Nitoń authored
42
43
        write_stats('data/stats_%s_all.txt' % now, all_stats_dict_all)
        write_stats('data/stats_%s_verified.txt' % now, all_stats_dict_verified)