mirror of
https://github.com/LC044/WeChatMsg
synced 2025-04-29 09:18:18 +08:00
delete redundant parameters
This commit is contained in:
parent
8fead399ba
commit
c40db420a1
@ -124,26 +124,18 @@ class Msg:
|
|||||||
lock.release()
|
lock.release()
|
||||||
return result[0]
|
return result[0]
|
||||||
|
|
||||||
def get_messages_length_with_ta(self, username_, is_Annual_report_=False, year_='2023'):
|
def get_messages_length_with_ta(self, username_, year_='all'):
|
||||||
if is_Annual_report_:
|
sql = f'''
|
||||||
sql = '''
|
|
||||||
select count(*)
|
|
||||||
from MSG
|
|
||||||
WHERE StrTalker = ? AND strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?
|
|
||||||
'''
|
|
||||||
else:
|
|
||||||
sql = '''
|
|
||||||
select count(*)
|
select count(*)
|
||||||
from MSG
|
from MSG
|
||||||
|
WHERE StrTalker = ?
|
||||||
|
{"and strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?" if year_ != "all" else ""}
|
||||||
'''
|
'''
|
||||||
if not self.open_flag:
|
if not self.open_flag:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
lock.acquire(True)
|
lock.acquire(True)
|
||||||
if is_Annual_report_:
|
self.cursor.execute(sql, [username_, year_] if year_ != "all" else [username_])
|
||||||
self.cursor.execute(sql, [username_, year_])
|
|
||||||
else:
|
|
||||||
self.cursor.execute(sql, [username_])
|
|
||||||
result = self.cursor.fetchone()
|
result = self.cursor.fetchone()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
result = None
|
result = None
|
||||||
@ -173,29 +165,20 @@ class Msg:
|
|||||||
# result.sort(key=lambda x: x[5])
|
# result.sort(key=lambda x: x[5])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_messages_by_type(self, username_, type_, is_Annual_report_=False, year_='2023'):
|
def get_messages_by_type(self, username_, type_, year_='all'):
|
||||||
if not self.open_flag:
|
if not self.open_flag:
|
||||||
return None
|
return None
|
||||||
if is_Annual_report_:
|
|
||||||
sql = '''
|
sql = f'''
|
||||||
select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID,BytesExtra,CompressContent
|
|
||||||
from MSG
|
|
||||||
where StrTalker=? and Type=? and strftime('%Y',CreateTime,'unixepoch','localtime') = ?
|
|
||||||
order by CreateTime
|
|
||||||
'''
|
|
||||||
else:
|
|
||||||
sql = '''
|
|
||||||
select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID,BytesExtra,CompressContent
|
select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID,BytesExtra,CompressContent
|
||||||
from MSG
|
from MSG
|
||||||
where StrTalker=? and Type=?
|
where StrTalker=? and Type=?
|
||||||
|
{"and strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?" if year_ != "all" else ""}
|
||||||
order by CreateTime
|
order by CreateTime
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
lock.acquire(True)
|
lock.acquire(True)
|
||||||
if is_Annual_report_:
|
self.cursor.execute(sql, [username_, type_, year_]if year_ != "all" else [username_, type_])
|
||||||
self.cursor.execute(sql, [username_, type_, year_])
|
|
||||||
else:
|
|
||||||
self.cursor.execute(sql, [username_, type_])
|
|
||||||
result = self.cursor.fetchall()
|
result = self.cursor.fetchall()
|
||||||
finally:
|
finally:
|
||||||
lock.release()
|
lock.release()
|
||||||
@ -270,59 +253,37 @@ class Msg:
|
|||||||
contacts.sort(key=lambda cur_contact: cur_contact[-1], reverse=True)
|
contacts.sort(key=lambda cur_contact: cur_contact[-1], reverse=True)
|
||||||
return contacts
|
return contacts
|
||||||
|
|
||||||
def get_messages_by_days(self, username_, is_Annual_report_=False, year_='2023'):
|
def get_messages_by_days(self, username_, year_='all'):
|
||||||
if is_Annual_report_:
|
sql = f'''
|
||||||
sql = '''
|
|
||||||
SELECT strftime('%Y-%m-%d',CreateTime,'unixepoch','localtime') as days,count(MsgSvrID)
|
|
||||||
from (
|
|
||||||
SELECT MsgSvrID, CreateTime
|
|
||||||
FROM MSG
|
|
||||||
WHERE StrTalker = ? AND strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?
|
|
||||||
)
|
|
||||||
group by days
|
|
||||||
'''
|
|
||||||
else:
|
|
||||||
sql = '''
|
|
||||||
SELECT strftime('%Y-%m-%d',CreateTime,'unixepoch','localtime') as days,count(MsgSvrID)
|
SELECT strftime('%Y-%m-%d',CreateTime,'unixepoch','localtime') as days,count(MsgSvrID)
|
||||||
from (
|
from (
|
||||||
SELECT MsgSvrID, CreateTime
|
SELECT MsgSvrID, CreateTime
|
||||||
FROM MSG
|
FROM MSG
|
||||||
WHERE StrTalker = ?
|
WHERE StrTalker = ?
|
||||||
|
{"and strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?" if year_ != "all" else ""}
|
||||||
)
|
)
|
||||||
group by days
|
group by days
|
||||||
'''
|
'''
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
if not self.open_flag:
|
if not self.open_flag:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
lock.acquire(True)
|
lock.acquire(True)
|
||||||
if is_Annual_report_:
|
self.cursor.execute(sql, [username_, year_]if year_ != "all" else [username_])
|
||||||
self.cursor.execute(sql, [username_, year_])
|
|
||||||
else:
|
|
||||||
self.cursor.execute(sql, [username_])
|
|
||||||
result = self.cursor.fetchall()
|
result = self.cursor.fetchall()
|
||||||
finally:
|
finally:
|
||||||
lock.release()
|
lock.release()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_messages_by_month(self, username_, is_Annual_report_=False, year_='2023'):
|
def get_messages_by_month(self, username_, year_='all'):
|
||||||
if is_Annual_report_:
|
sql = f'''
|
||||||
sql = '''
|
|
||||||
SELECT strftime('%Y-%m',CreateTime,'unixepoch','localtime') as days,count(MsgSvrID)
|
|
||||||
from (
|
|
||||||
SELECT MsgSvrID, CreateTime
|
|
||||||
FROM MSG
|
|
||||||
WHERE StrTalker = ? AND strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?
|
|
||||||
)
|
|
||||||
group by days
|
|
||||||
'''
|
|
||||||
else:
|
|
||||||
sql = '''
|
|
||||||
SELECT strftime('%Y-%m',CreateTime,'unixepoch','localtime') as days,count(MsgSvrID)
|
SELECT strftime('%Y-%m',CreateTime,'unixepoch','localtime') as days,count(MsgSvrID)
|
||||||
from (
|
from (
|
||||||
SELECT MsgSvrID, CreateTime
|
SELECT MsgSvrID, CreateTime
|
||||||
FROM MSG
|
FROM MSG
|
||||||
WHERE StrTalker = ?
|
WHERE StrTalker = ?
|
||||||
|
{"and strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?" if year_ != "all" else ""}
|
||||||
)
|
)
|
||||||
group by days
|
group by days
|
||||||
'''
|
'''
|
||||||
@ -331,10 +292,7 @@ class Msg:
|
|||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
lock.acquire(True)
|
lock.acquire(True)
|
||||||
if is_Annual_report_:
|
self.cursor.execute(sql, [username_, year_] if year_ != "all" else [username_])
|
||||||
self.cursor.execute(sql, [username_, year_])
|
|
||||||
else:
|
|
||||||
self.cursor.execute(sql, [username_])
|
|
||||||
result = self.cursor.fetchall()
|
result = self.cursor.fetchall()
|
||||||
except sqlite3.DatabaseError:
|
except sqlite3.DatabaseError:
|
||||||
logger.error(f'{traceback.format_exc()}\n数据库损坏请删除msg文件夹重试')
|
logger.error(f'{traceback.format_exc()}\n数据库损坏请删除msg文件夹重试')
|
||||||
@ -343,24 +301,14 @@ class Msg:
|
|||||||
# result.sort(key=lambda x: x[5])
|
# result.sort(key=lambda x: x[5])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_messages_by_hour(self, username_, is_Annual_report_=False, year_='2023'):
|
def get_messages_by_hour(self, username_, year_='all'):
|
||||||
if is_Annual_report_:
|
sql = f'''
|
||||||
sql = '''
|
|
||||||
SELECT strftime('%H:00',CreateTime,'unixepoch','localtime') as hours,count(MsgSvrID)
|
|
||||||
from (
|
|
||||||
SELECT MsgSvrID, CreateTime
|
|
||||||
FROM MSG
|
|
||||||
where StrTalker = ? and strftime('%Y',CreateTime,'unixepoch','localtime') = ?
|
|
||||||
)
|
|
||||||
group by hours
|
|
||||||
'''
|
|
||||||
else:
|
|
||||||
sql = '''
|
|
||||||
SELECT strftime('%H:00',CreateTime,'unixepoch','localtime') as hours,count(MsgSvrID)
|
SELECT strftime('%H:00',CreateTime,'unixepoch','localtime') as hours,count(MsgSvrID)
|
||||||
from (
|
from (
|
||||||
SELECT MsgSvrID, CreateTime
|
SELECT MsgSvrID, CreateTime
|
||||||
FROM MSG
|
FROM MSG
|
||||||
where StrTalker = ?
|
where StrTalker = ?
|
||||||
|
{"and strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?" if year_ != "all" else ""}
|
||||||
)
|
)
|
||||||
group by hours
|
group by hours
|
||||||
'''
|
'''
|
||||||
@ -369,10 +317,7 @@ class Msg:
|
|||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
lock.acquire(True)
|
lock.acquire(True)
|
||||||
if is_Annual_report_:
|
self.cursor.execute(sql, [username_, year_] if year_ != "all" else [username_])
|
||||||
self.cursor.execute(sql, [username_, year_])
|
|
||||||
else:
|
|
||||||
self.cursor.execute(sql, [username_])
|
|
||||||
result = self.cursor.fetchall()
|
result = self.cursor.fetchall()
|
||||||
except sqlite3.DatabaseError:
|
except sqlite3.DatabaseError:
|
||||||
logger.error(f'{traceback.format_exc()}\n数据库损坏请删除msg文件夹重试')
|
logger.error(f'{traceback.format_exc()}\n数据库损坏请删除msg文件夹重试')
|
||||||
@ -381,14 +326,14 @@ class Msg:
|
|||||||
# result.sort(key=lambda x: x[5])
|
# result.sort(key=lambda x: x[5])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_lateDay_messages(self, username_, is_Annual_report_=False, year_='2023'):
|
def get_lateDay_messages(self, username_, year_='all'):
|
||||||
if is_Annual_report_:
|
sql = f'''
|
||||||
sql = '''
|
SELECT strftime('%Y-%m-%d %H:%M:%S', CreateTime, 'unixepoch', 'localtime') as Strtime, IsSender, Status, StrContent
|
||||||
SELECT strftime('%Y-%m-%d %H:%M:%S', CreateTime, 'unixepoch', 'localtime') as time, IsSender, Status, StrContent
|
|
||||||
from(
|
from(
|
||||||
SELECT CreateTime, strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') as time, IsSender, Status, StrContent
|
SELECT CreateTime, strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') as time, IsSender, Status, StrContent
|
||||||
FROM MSG
|
FROM MSG
|
||||||
WHERE StrTalker = ? AND strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?
|
WHERE StrTalker = ?
|
||||||
|
{"and strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?" if year_ != "all" else ""}
|
||||||
AND (strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') > ?
|
AND (strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') > ?
|
||||||
or strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') < ? ) AND Type=1
|
or strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') < ? ) AND Type=1
|
||||||
ORDER BY CASE
|
ORDER BY CASE
|
||||||
@ -398,30 +343,12 @@ class Msg:
|
|||||||
LIMIT 4
|
LIMIT 4
|
||||||
)
|
)
|
||||||
'''
|
'''
|
||||||
else:
|
|
||||||
sql = '''
|
|
||||||
SELECT strftime('%Y-%m-%d %H:%M:%S', CreateTime, 'unixepoch', 'localtime') as time, IsSender, Status, StrContent
|
|
||||||
from(
|
|
||||||
SELECT CreateTime, strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') as time, IsSender, Status, StrContent
|
|
||||||
FROM MSG
|
|
||||||
WHERE StrTalker = ? AND (strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') > ?
|
|
||||||
or strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') < ? ) AND Type=1
|
|
||||||
ORDER BY CASE
|
|
||||||
WHEN strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') < ? THEN 0
|
|
||||||
ELSE 1
|
|
||||||
END, time DESC
|
|
||||||
LIMIT 4
|
|
||||||
)
|
|
||||||
'''
|
|
||||||
result = None
|
result = None
|
||||||
if not self.open_flag:
|
if not self.open_flag:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
lock.acquire(True)
|
lock.acquire(True)
|
||||||
if is_Annual_report_:
|
self.cursor.execute(sql, [username_, year_, '21:00:00', '05:00:00', '05:00:00'] if year_ != "all" else [username_, '21:00:00', '05:00:00', '05:00:00'])
|
||||||
self.cursor.execute(sql, [username_, year_, '21:00:00', '05:00:00', '05:00:00'])
|
|
||||||
else:
|
|
||||||
self.cursor.execute(sql, [username_, '21:00:00', '05:00:00', '05:00:00'])
|
|
||||||
result = self.cursor.fetchall()
|
result = self.cursor.fetchall()
|
||||||
except sqlite3.DatabaseError:
|
except sqlite3.DatabaseError:
|
||||||
logger.error(f'{traceback.format_exc()}\n数据库损坏请删除msg文件夹重试')
|
logger.error(f'{traceback.format_exc()}\n数据库损坏请删除msg文件夹重试')
|
||||||
@ -430,39 +357,25 @@ class Msg:
|
|||||||
# result.sort(key=lambda x: x[5])
|
# result.sort(key=lambda x: x[5])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_earlyDay_messages(self, username_, is_Annual_report_=False, year_='2023'):
|
def get_earlyDay_messages(self, username_, year_='all'):
|
||||||
if is_Annual_report_:
|
sql = f'''
|
||||||
sql = '''
|
|
||||||
SELECT strftime('%Y-%m-%d %H:%M:%S', CreateTime, 'unixepoch', 'localtime') as strtime, IsSender, Status, StrContent
|
SELECT strftime('%Y-%m-%d %H:%M:%S', CreateTime, 'unixepoch', 'localtime') as strtime, IsSender, Status, StrContent
|
||||||
from (
|
from (
|
||||||
SELECT CreateTime, strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') as time, IsSender, Status, StrContent
|
SELECT CreateTime, strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') as time, IsSender, Status, StrContent
|
||||||
FROM MSG
|
FROM MSG
|
||||||
WHERE StrTalker = ? AND strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?
|
WHERE StrTalker = ?
|
||||||
|
{"and strftime('%Y', CreateTime, 'unixepoch', 'localtime') = ?" if year_ != "all" else ""}
|
||||||
AND strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') > ? AND Type=1
|
AND strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') > ? AND Type=1
|
||||||
ORDER BY time
|
ORDER BY time
|
||||||
LIMIT 4
|
LIMIT 4
|
||||||
)
|
)
|
||||||
'''
|
'''
|
||||||
else:
|
|
||||||
sql = '''
|
|
||||||
SELECT strftime('%Y-%m-%d %H:%M:%S', CreateTime, 'unixepoch', 'localtime') as strtime, IsSender, Status, StrContent
|
|
||||||
from (
|
|
||||||
SELECT CreateTime, strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') as time, IsSender, Status, StrContent
|
|
||||||
FROM MSG
|
|
||||||
WHERE StrTalker = ? AND strftime('%H:%M:%S', CreateTime, 'unixepoch', 'localtime') > ? AND Type=1
|
|
||||||
ORDER BY time
|
|
||||||
LIMIT 4
|
|
||||||
)
|
|
||||||
'''
|
|
||||||
result = None
|
result = None
|
||||||
if not self.open_flag:
|
if not self.open_flag:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
lock.acquire(True)
|
lock.acquire(True)
|
||||||
if is_Annual_report_:
|
self.cursor.execute(sql, [username_, year_, '05:00:00'] if year_ != "all" else [username_, '05:00:00'])
|
||||||
self.cursor.execute(sql, [username_, year_, '05:00:00'])
|
|
||||||
else:
|
|
||||||
self.cursor.execute(sql, [username_, '05:00:00'])
|
|
||||||
result = self.cursor.fetchall()
|
result = self.cursor.fetchall()
|
||||||
except sqlite3.DatabaseError:
|
except sqlite3.DatabaseError:
|
||||||
logger.error(f'{traceback.format_exc()}\n数据库损坏请删除msg文件夹重试')
|
logger.error(f'{traceback.format_exc()}\n数据库损坏请删除msg文件夹重试')
|
||||||
|
@ -21,9 +21,9 @@ wordcloud_width = 780
|
|||||||
wordcloud_height = 720
|
wordcloud_height = 720
|
||||||
|
|
||||||
|
|
||||||
def wordcloud(wxid, is_Annual_report=False, year='2023', who='1'):
|
def wordcloud(wxid, year='all', who='1'):
|
||||||
import jieba
|
import jieba
|
||||||
txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT, is_Annual_report, year)
|
txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT, year)
|
||||||
if not txt_messages:
|
if not txt_messages:
|
||||||
return {
|
return {
|
||||||
'chart_data': None,
|
'chart_data': None,
|
||||||
@ -75,10 +75,10 @@ def wordcloud(wxid, is_Annual_report=False, year='2023', who='1'):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def calendar_chart(wxid, is_Annual_report=False, year='2023'):
|
def calendar_chart(wxid, year='all'):
|
||||||
data_length = msg_db.get_messages_length_with_ta(wxid, is_Annual_report, year) # 获取和他的聊天条数
|
data_length = msg_db.get_messages_length_with_ta(wxid, year) # 获取和他的聊天条数
|
||||||
print(f'聊天总数:{data_length}')
|
print(f'聊天总数:{data_length}')
|
||||||
calendar_data = msg_db.get_messages_by_days(wxid, is_Annual_report, year)
|
calendar_data = msg_db.get_messages_by_days(wxid, year)
|
||||||
|
|
||||||
if not calendar_data:
|
if not calendar_data:
|
||||||
return False
|
return False
|
||||||
@ -99,7 +99,7 @@ def calendar_chart(wxid, is_Annual_report=False, year='2023'):
|
|||||||
date_num = (date2 - date1).days + 1
|
date_num = (date2 - date1).days + 1
|
||||||
print(date_num)
|
print(date_num)
|
||||||
|
|
||||||
if is_Annual_report:
|
if year != 'all':
|
||||||
calendar_days = year
|
calendar_days = year
|
||||||
calendar_title = f'{year}年聊天情况'
|
calendar_title = f'{year}年聊天情况'
|
||||||
else:
|
else:
|
||||||
@ -127,7 +127,7 @@ def calendar_chart(wxid, is_Annual_report=False, year='2023'):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
'chart_data': c,
|
'chart_data': c.dump_options_with_quotes(),
|
||||||
'data_length': data_length, # 和xx的聊天记录总数
|
'data_length': data_length, # 和xx的聊天记录总数
|
||||||
'max_date': formatted_date,
|
'max_date': formatted_date,
|
||||||
'max_num': str(max_),
|
'max_num': str(max_),
|
||||||
@ -136,19 +136,23 @@ def calendar_chart(wxid, is_Annual_report=False, year='2023'):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def month_count(wxid, is_Annual_report=False, year='2023'):
|
def month_count(wxid, year='all'):
|
||||||
"""
|
"""
|
||||||
每月聊天条数
|
每月聊天条数
|
||||||
"""
|
"""
|
||||||
msg_data = msg_db.get_messages_by_month(wxid, is_Annual_report, year)
|
msg_data = msg_db.get_messages_by_month(wxid, year)
|
||||||
y_data = list(map(lambda x: x[1], msg_data))
|
y_data = list(map(lambda x: x[1], msg_data))
|
||||||
x_axis = list(map(lambda x: x[0], msg_data))
|
x_axis = list(map(lambda x: x[0], msg_data))
|
||||||
# 获取聊天的月数
|
# 获取聊天的月数
|
||||||
|
if year != 'all':
|
||||||
if all(y > 0 for y in y_data):
|
if all(y > 0 for y in y_data):
|
||||||
conc = "我们这一年每个月都有在聊天"
|
conc = "我们这一年每个月都有在聊天"
|
||||||
else:
|
else:
|
||||||
months_with_chat = sum(1 for y in y_data if y > 0)
|
months_with_chat = sum(1 for y in y_data if y > 0)
|
||||||
conc = f"我们这一年有{months_with_chat}个月都在聊天"
|
conc = f"我们这一年有{months_with_chat}个月都在聊天"
|
||||||
|
else:
|
||||||
|
months_with_chat = sum(1 for y in y_data if y > 0)
|
||||||
|
conc = f"我们有{months_with_chat}个月都在聊天"
|
||||||
print("聊天月数", conc)
|
print("聊天月数", conc)
|
||||||
# 月平均聊天条数
|
# 月平均聊天条数
|
||||||
average_num = round(sum(y_data)/12)
|
average_num = round(sum(y_data)/12)
|
||||||
@ -194,11 +198,11 @@ def month_count(wxid, is_Annual_report=False, year='2023'):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def hour_count(wxid, is_Annual_report=False, year='2023'):
|
def hour_count(wxid, year='all'):
|
||||||
"""
|
"""
|
||||||
小时计数聊天条数
|
小时计数聊天条数
|
||||||
"""
|
"""
|
||||||
msg_data = msg_db.get_messages_by_hour(wxid, is_Annual_report, year)
|
msg_data = msg_db.get_messages_by_hour(wxid, year)
|
||||||
print(msg_data)
|
print(msg_data)
|
||||||
y_data = list(map(lambda x: x[1], msg_data))
|
y_data = list(map(lambda x: x[1], msg_data))
|
||||||
x_axis = list(map(lambda x: x[0], msg_data))
|
x_axis = list(map(lambda x: x[0], msg_data))
|
||||||
@ -232,8 +236,8 @@ def hour_count(wxid, is_Annual_report=False, year='2023'):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
late_data = msg_db.get_lateDay_messages(wxid, is_Annual_report, year) # 最晚的消息记录
|
late_data = msg_db.get_lateDay_messages(wxid, year) # 最晚的消息记录
|
||||||
early_data = msg_db.get_earlyDay_messages(wxid, is_Annual_report, year) # 早上最早的记录
|
early_data = msg_db.get_earlyDay_messages(wxid, year) # 早上最早的记录
|
||||||
print(late_data)
|
print(late_data)
|
||||||
print(early_data)
|
print(early_data)
|
||||||
return {
|
return {
|
||||||
@ -245,9 +249,9 @@ def hour_count(wxid, is_Annual_report=False, year='2023'):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def emoji_count(wxid, is_Annual_report=False, year='2023'):
|
def emoji_count(wxid, year='all'):
|
||||||
# 最常发的表情
|
# 最常发的表情
|
||||||
txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT, is_Annual_report, year)
|
txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT, year)
|
||||||
me_txt_messages = ''.join(map(lambda x: x[7] if x[4] == 1 else '', txt_messages))
|
me_txt_messages = ''.join(map(lambda x: x[7] if x[4] == 1 else '', txt_messages))
|
||||||
ta_txt_messages = ''.join(map(lambda x: x[7] if x[4] == 0 else '', txt_messages))
|
ta_txt_messages = ''.join(map(lambda x: x[7] if x[4] == 0 else '', txt_messages))
|
||||||
|
|
||||||
@ -296,16 +300,16 @@ class Analysis:
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
msg_db.init_database(path='../DataBase/Msg/MSG.db')
|
msg_db.init_database(path='../DataBase/Msg/MSG.db')
|
||||||
# w = wordcloud('wxid_0o18ef858vnu22')
|
# w = wordcloud('wxid_0o18ef858vnu22')
|
||||||
# w_data = wordcloud('wxid_27hqbq7vx5hf22', True, '2023')
|
w_data = wordcloud('wxid_27hqbq7vx5hf22', '2023')
|
||||||
# # print(w_data)
|
# # print(w_data)
|
||||||
# # w['chart_data'].render("./data/聊天统计/wordcloud.html")
|
# # w['chart_data'].render("./data/聊天统计/wordcloud.html")
|
||||||
# c = calendar_chart('wxid_27hqbq7vx5hf22', False, '2023')
|
c = calendar_chart('wxid_27hqbq7vx5hf22', '2023')
|
||||||
# c['chart_data'].render("./data/聊天统计/calendar.html")
|
# c['chart_data'].render("./data/聊天统计/calendar.html")
|
||||||
# # print('c:::', c)
|
# # print('c:::', c)
|
||||||
# m = month_count('wxid_27hqbq7vx5hf22', False, '2023')
|
m = month_count('wxid_27hqbq7vx5hf22', False, '2023')
|
||||||
# m['chart_data'].render("./data/聊天统计/month_num.html")
|
# m['chart_data'].render("./data/聊天统计/month_num.html")
|
||||||
# h = hour_count('wxid_27hqbq7vx5hf22',is_Annual_report=False)
|
# h = hour_count('wxid_27hqbq7vx5hf22')
|
||||||
# h['chart_data'].render("./data/聊天统计/hour_count.html")
|
# h['chart_data'].render("./data/聊天统计/hour_count.html")
|
||||||
|
|
||||||
h = emoji_count('wxid_27hqbq7vx5hf22',is_Annual_report=False)
|
h = emoji_count('wxid_27hqbq7vx5hf22')
|
||||||
# h['chart_data'].render("./data/聊天统计/hour_count.html")
|
# h['chart_data'].render("./data/聊天统计/hour_count.html")
|
||||||
|
Loading…
Reference in New Issue
Block a user