-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper_func.py
52 lines (40 loc) · 1.71 KB
/
helper_func.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
from flask import request
import time
import datetime
from crm_data import student_list, magic, courses, houses
def skills_list(status):
levels = []
for i in range(0, len(magic)):
levels.append(request.form.get(status + ' ' + magic[i]))
skills = [magic[i] + " " + levels[i]
for i in range(0, len(magic)) if levels[i] is not '0']
return skills
def get_crm_skills_record(_target_magic):
global student_list
global magic
all_magic = []
for student in student_list:
student_magic_list = [magic.split()[0]
for magic in student_list[student][_target_magic]]
all_magic.append(student_magic_list)
flatlist_magic = [item for sublist in all_magic for item in sublist]
skill_counter = [flatlist_magic.count(skill) for skill in magic]
return skill_counter
def get_crm_time_year(_target_timestamp):
global student_list
unixtime_list = [student_list[key][_target_timestamp] for key in student_list]
datetime_yr = [int(datetime.datetime.fromtimestamp(
unixtime).strftime('%Y')) for unixtime in unixtime_list]
year_unique = sorted(set(datetime_yr))
year_counter = [datetime_yr.count(year) for year in year_unique]
return year_unique, year_counter
def convert_time(_label):
global student_list
unixtime_list = [student_list[student][_label] for student in student_list]
datetime_list = [datetime.datetime.fromtimestamp(unixtime).strftime(
'%Y-%m-%d %H:%M:%S') for unixtime in unixtime_list]
student_key = [key for key in student_list]
datetime_dict = {}
for i in range(0, len(datetime_list)):
datetime_dict[student_key[i]] = datetime_list[i]
return datetime_dict