mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-14 22:01:54 +08:00
修复没有聊天的好友年度报告的bug
This commit is contained in:
parent
80d669d7d4
commit
ebc62c33e1
@ -117,13 +117,13 @@ def wordcloud_christmas(wxid, year='2023'):
|
|||||||
.add(series_name="聊天文字", data_pair=text_data, word_size_range=[5, 40])
|
.add(series_name="聊天文字", data_pair=text_data, word_size_range=[5, 40])
|
||||||
)
|
)
|
||||||
# return w.render_embed()
|
# return w.render_embed()
|
||||||
dialogs = msg_db.get_messages_by_keyword(wxid, keyword, num=3, max_len=12,year_=year)
|
dialogs = msg_db.get_messages_by_keyword(wxid, keyword, num=3, max_len=12, year_=year)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'wordcloud_chart_data': w.dump_options_with_quotes(),
|
'wordcloud_chart_data': w.dump_options_with_quotes(),
|
||||||
'keyword': keyword,
|
'keyword': keyword,
|
||||||
'keyword_max_num': str(max_num),
|
'keyword_max_num': str(max_num),
|
||||||
'dialogs':dialogs ,
|
'dialogs': dialogs,
|
||||||
'total_num': total_msg_len,
|
'total_num': total_msg_len,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,11 +133,14 @@ def calendar_chart(wxid, is_Annual_report=False, year='2023'):
|
|||||||
calendar_data = msg_db.get_messages_by_days(wxid, is_Annual_report, year)
|
calendar_data = msg_db.get_messages_by_days(wxid, is_Annual_report, year)
|
||||||
except:
|
except:
|
||||||
return {
|
return {
|
||||||
'calendar_chart_data': None,
|
'calendar_chart_data': None,
|
||||||
'chat_days':0,
|
'chat_days': 0,
|
||||||
}
|
}
|
||||||
if not calendar_data:
|
if not calendar_data:
|
||||||
return False
|
return {
|
||||||
|
'calendar_chart_data': None,
|
||||||
|
'chat_days': 0,
|
||||||
|
}
|
||||||
min_ = min(map(lambda x: x[1], calendar_data))
|
min_ = min(map(lambda x: x[1], calendar_data))
|
||||||
max_ = max(map(lambda x: x[1], calendar_data))
|
max_ = max(map(lambda x: x[1], calendar_data))
|
||||||
start_date_ = calendar_data[0][0]
|
start_date_ = calendar_data[0][0]
|
||||||
@ -169,7 +172,7 @@ def calendar_chart(wxid, is_Annual_report=False, year='2023'):
|
|||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
'calendar_chart_data': c.dump_options_with_quotes(),
|
'calendar_chart_data': c.dump_options_with_quotes(),
|
||||||
'chat_days':len(calendar_data),
|
'chat_days': len(calendar_data),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class ScrollBar(QScrollBar):
|
|||||||
border-width: 0px;
|
border-width: 0px;
|
||||||
border: none;
|
border: none;
|
||||||
background:rgba(133, 135, 138, 0);
|
background:rgba(133, 135, 138, 0);
|
||||||
width:2px;
|
width:4px;
|
||||||
margin: 0px 0px 0px 0px;
|
margin: 0px 0px 0px 0px;
|
||||||
}
|
}
|
||||||
QScrollBar::handle:vertical {
|
QScrollBar::handle:vertical {
|
||||||
|
@ -178,7 +178,7 @@ def get_most_emoji(messages):
|
|||||||
md5_nums = [(num[0], key, num[1]) for key, num in dic.items()]
|
md5_nums = [(num[0], key, num[1]) for key, num in dic.items()]
|
||||||
md5_nums.sort(key=lambda x: x[0],reverse=True)
|
md5_nums.sort(key=lambda x: x[0],reverse=True)
|
||||||
if not md5_nums:
|
if not md5_nums:
|
||||||
return ''
|
return '',0
|
||||||
md5 = md5_nums[0][1]
|
md5 = md5_nums[0][1]
|
||||||
num = md5_nums[0][0]
|
num = md5_nums[0][0]
|
||||||
emoji_info = md5_nums[0][2]
|
emoji_info = md5_nums[0][2]
|
||||||
|
@ -42,7 +42,7 @@ def christmas():
|
|||||||
'正常作息': {'06:00', "07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00",
|
'正常作息': {'06:00', "07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00",
|
||||||
"17:00", "18:00", "19:00", "20:00", "21:00"},
|
"17:00", "18:00", "19:00", "20:00", "21:00"},
|
||||||
}
|
}
|
||||||
time_, num = msg_data[0]
|
time_, num = msg_data[0] if msg_data else '', 0
|
||||||
chat_time = f"凌晨{time_}" if time_ in {'00:00', '01:00', '02:00', '03:00', '04:00', '05:00'} else time_
|
chat_time = f"凌晨{time_}" if time_ in {'00:00', '01:00', '02:00', '03:00', '04:00', '05:00'} else time_
|
||||||
label = '夜猫子'
|
label = '夜猫子'
|
||||||
for key, item in desc.items():
|
for key, item in desc.items():
|
||||||
@ -63,28 +63,29 @@ def christmas():
|
|||||||
month_data.sort(key=lambda x: x[1])
|
month_data.sort(key=lambda x: x[1])
|
||||||
max_month, max_num = month_data[-1]
|
max_month, max_num = month_data[-1]
|
||||||
min_month, min_num = month_data[0]
|
min_month, min_num = month_data[0]
|
||||||
min_month = min_month[-2:].lstrip('0')+'月'
|
min_month = min_month[-2:].lstrip('0') + '月'
|
||||||
max_month = max_month[-2:].lstrip('0')+'月'
|
max_month = max_month[-2:].lstrip('0') + '月'
|
||||||
else:
|
else:
|
||||||
max_month, max_num = '月份', 0
|
max_month, max_num = '月份', 0
|
||||||
min_month, min_num = '月份', 0
|
min_month, min_num = '月份', 0
|
||||||
month_data = {
|
month_data = {
|
||||||
'year':'2023',
|
'year': '2023',
|
||||||
'total_msg_num':msg_db.get_messages_number(contact.wxid,'2023'),
|
'total_msg_num': msg_db.get_messages_number(contact.wxid, '2023'),
|
||||||
'max_month':max_month,
|
'max_month': max_month,
|
||||||
'min_month':min_month,
|
'min_month': min_month,
|
||||||
'max_month_num':max_num,
|
'max_month_num': max_num,
|
||||||
'min_month_num':min_num,
|
'min_month_num': min_num,
|
||||||
}
|
}
|
||||||
calendar_data = analysis.calendar_chart(contact.wxid,True,year='2023')
|
calendar_data = analysis.calendar_chart(contact.wxid, True, year='2023')
|
||||||
emoji_msgs = msg_db.get_messages_by_type(contact.wxid,47,year_='2023')
|
emoji_msgs = msg_db.get_messages_by_type(contact.wxid, 47, year_='2023')
|
||||||
url,num = get_most_emoji(emoji_msgs)
|
url, num = get_most_emoji(emoji_msgs)
|
||||||
emoji_data = {
|
emoji_data = {
|
||||||
'emoji_total_num':len(emoji_msgs),
|
'emoji_total_num': len(emoji_msgs),
|
||||||
'emoji_url':url,
|
'emoji_url': url,
|
||||||
'emoji_num':num,
|
'emoji_num': num,
|
||||||
}
|
}
|
||||||
return render_template("christmas.html", **data, **wordcloud_cloud_data, **time_data,**month_data,**calendar_data,**emoji_data)
|
return render_template("christmas.html", **data, **wordcloud_cloud_data, **time_data, **month_data, **calendar_data,
|
||||||
|
**emoji_data)
|
||||||
|
|
||||||
|
|
||||||
# @app.route("/")
|
# @app.route("/")
|
||||||
|
Loading…
Reference in New Issue
Block a user