-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathstatistic_plugin.py
58 lines (46 loc) · 1.66 KB
/
statistic_plugin.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
# -*- coding: utf-8 -*-
from log.my_logger import statistic_logger as my_logger
from statistic.statistic_handler import StatisticHandler
from utils import global_config
from utils.config_reader import ConfigReader
from utils.scheduler import scheduler
@scheduler.scheduled_job('cron', minute='45', hour=2)
def read_statistic_conf():
global statistic_handler
my_logger.debug('读取数据配置-statistic_plugin')
ConfigReader.read_conf()
# @scheduler.scheduled_job('cron', hour=3)
def record_data():
"""
记录数据
:return:
"""
global statistic_handler
try:
my_logger.debug(global_config.POCKET48_LISTEN_TASKS)
for task in global_config.POCKET48_LISTEN_TASKS:
my_logger.debug('member name: %s', task.member.name)
my_logger.debug('记录群人数数据')
statistic_handler.update_group_size(task.member.pinyin)
my_logger.debug('记录超话数据')
statistic_handler.get_super_tag_size(task.member.pinyin)
except Exception as exp:
my_logger.exception(exp)
@scheduler.scheduled_job('cron', hour=3, minute=10)
def record_bilibili_data():
global statistic_handler
try:
my_logger.info('记录b站数据')
statistic_handler.get_bilibili_stat()
except Exception as e:
my_logger.exception(e)
@scheduler.scheduled_job('cron', hour=1, minute=5)
def record_pocket_room_data():
global statistic_handler
try:
my_logger.info('记录口袋房间数据')
statistic_handler.pocket_msgs()
except Exception as e:
my_logger.exception(e)
statistic_handler = StatisticHandler('statistics.db')
read_statistic_conf()