mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-14 22:01:54 +08:00
commit
f132796fd6
@ -188,6 +188,24 @@ class Msg:
|
||||
|
||||
return res
|
||||
|
||||
def get_messages_by_days(self, username_, year_='2023'):
|
||||
sql = '''
|
||||
SELECT strftime('%Y-%m-%d',CreateTime,'unixepoch','localtime') as days,count(MsgSvrID)
|
||||
from MSG
|
||||
where StrTalker = ? and strftime('%Y',CreateTime,'unixepoch','localtime') = ?
|
||||
group by days
|
||||
'''
|
||||
result = None
|
||||
if not self.open_flag:
|
||||
return None
|
||||
try:
|
||||
lock.acquire(True)
|
||||
self.cursor.execute(sql, [username_, year_])
|
||||
result = self.cursor.fetchall()
|
||||
finally:
|
||||
lock.release()
|
||||
return result
|
||||
|
||||
def get_first_time_of_message(self, username_):
|
||||
if not self.open_flag:
|
||||
return None
|
||||
@ -231,4 +249,4 @@ if __name__ == '__main__':
|
||||
pprint(msg.get_message_by_num('wxid_0o18ef858vnu22', local_id))
|
||||
print(msg.get_messages_by_keyword(wxid, '干嘛'))
|
||||
pprint(msg.get_messages_by_keyword(wxid, '干嘛')[0])
|
||||
print(msg.get_first_time_of_message('wxid_fervbwign7m822'))
|
||||
print(msg.get_first_time_of_message('wxid_0o18ef858vnu22'))
|
@ -2,6 +2,9 @@ from collections import Counter
|
||||
|
||||
from PyQt5.QtCore import QFile, QTextStream, QIODevice
|
||||
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
|
||||
from app.DataBase import msg_db, MsgType
|
||||
from app.person_pc import ContactPC
|
||||
import jieba
|
||||
@ -76,11 +79,47 @@ def wordcloud(wxid):
|
||||
}
|
||||
|
||||
|
||||
def calendar_chart(wxid, year):
|
||||
calendar_data = msg_db.get_messages_by_days(wxid, year)
|
||||
|
||||
if not calendar_data:
|
||||
return False
|
||||
min_ = min(map(lambda x: x[1], calendar_data))
|
||||
max_ = max(map(lambda x: x[1], calendar_data))
|
||||
|
||||
c = (
|
||||
Calendar(init_opts=opts.InitOpts(width=f"{charts_width}px", height=f"{charts_height}px"))
|
||||
.add(
|
||||
"",
|
||||
calendar_data,
|
||||
calendar_opts=opts.CalendarOpts(range_=year)
|
||||
)
|
||||
.set_global_opts(
|
||||
title_opts=opts.TitleOpts(title="2023年聊天情况"),
|
||||
visualmap_opts=opts.VisualMapOpts(
|
||||
max_=max_,
|
||||
min_=min_,
|
||||
orient="horizontal",
|
||||
# is_piecewise=True,
|
||||
# pos_top="200px",
|
||||
pos_bottom="0px",
|
||||
pos_left="0px",
|
||||
),
|
||||
legend_opts=opts.LegendOpts(is_show=False)
|
||||
)
|
||||
)
|
||||
return {
|
||||
'chart_data': c
|
||||
}
|
||||
|
||||
|
||||
class Analysis:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
msg_db.init_database(path='../DataBase/Msg/MSG.db')
|
||||
w = wordcloud('wxid_0o18ef858vnu22')
|
||||
print(w)
|
||||
# w = wordcloud('wxid_0o18ef858vnu22')
|
||||
c = calendar_chart('wxid_27hqbq7vx5hf22', '2023')
|
||||
c['chart_data'].render("./data/聊天统计/calendar.html")
|
||||
print('c:::', c)
|
||||
|
Loading…
Reference in New Issue
Block a user