-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcalculate_statistics_data.py
executable file
·68 lines (55 loc) · 2.22 KB
/
calculate_statistics_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#==============================================================================
# This scripts does the calculations in all the statistic modules and in other
# models like the Talk_Persons module and the Talk-Module
#
# It is meant to be run as cronjob
#
# It filters all datasets with a recalculation-needed flag set and lets
# them execute the calculations
#
#
#==============================================================================
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "subtitleStatus.settings")
import django
django.setup()
#from django.db.models import Q
from www.models import Statistics_Raw_Data, Talk, Talk_Persons, Statistics_Speaker, Statistics_Event, Event
# Statistics_Raw_Data
my_statistics = Statistics_Raw_Data.objects.filter(recalculate_statistics = True)
for any_statistics in my_statistics:
any_statistics.refresh_from_db()
any_statistics.recalculate()
# Whole Talk Statistics
my_statistics = Talk.objects.filter(recalculate_talk_statistics = True)
for any_statistics in my_statistics:
any_statistics.refresh_from_db()
any_statistics.recalculate_whole_talk_statistics()
# Talk, only Speakers Time Statistics
my_statistics = Talk.objects.filter(recalculate_speakers_statistics = True)
for any_statistics in my_statistics:
any_statistics.refresh_from_db()
any_statistics.recalculate_speakers_in_talk_statistics()
# Create the entries for Statistics_Event if necessary, ignore #3
all_events = Event.objects.all().exclude(id = 3)
for any in all_events:
any.refresh_from_db()
any.create_statistics_event_entries()
# Event Statistics
my_statistics = Statistics_Event.objects.filter(recalculate_statistics = True)
for any_statistics in my_statistics:
any_statistics.refresh_from_db()
any_statistics.recalculate()
# Talk_Persons
my_statistics = Talk_Persons.objects.filter(recalculate_statistics = True)
for any_statistics in my_statistics:
any_statistics.refresh_from_db()
any_statistics.recalculate()
# Statistics Speakers
my_statistics = Statistics_Speaker.objects.filter(recalculate_statistics = True)
for any_statistics in my_statistics:
any_statistics.refresh_from_db()
any_statistics.recalculate()
print("Done!")