This commit is contained in:
ZaneYork 2024-09-12 10:39:55 +08:00
parent 1b61b35c03
commit e5af152d14
3 changed files with 5 additions and 3 deletions

View File

@ -107,7 +107,7 @@ def fetch_all_menu() -> Generator[tuple[str, str, str], None, None]:
db.close() db.close()
def fetch_roll_result() -> str|None: def fetch_roll_result() -> str | None:
""" """
获取N天前的抽签结果 获取N天前的抽签结果
:return: 抽签结果 :return: 抽签结果
@ -118,7 +118,7 @@ def fetch_roll_result() -> str|None:
cursor = db.cursor() cursor = db.cursor()
try: try:
cursor.execute("select value from roll_result where datestr=?", cursor.execute("select value from roll_result where datestr=?",
(datestr, )) (datestr,))
row = cursor.fetchone() row = cursor.fetchone()
if row is not None: if row is not None:
return row[0] return row[0]

View File

@ -55,6 +55,7 @@ def vote_reduce(summary: dict[str, float], limit: int = 2) -> tuple[dict[str, fl
""" """
按规则对投票结果进行修饰 按规则对投票结果进行修饰
:param summary: 投票汇总结果 :param summary: 投票汇总结果
:param limit: 降低最近N次点餐结果概率
:return: 投票汇总结果 :return: 投票汇总结果
""" """
last_results = list(fetch_roll_result_list(-1, limit)) last_results = list(fetch_roll_result_list(-1, limit))

View File

@ -3,10 +3,10 @@ from configparser import ConfigParser
from flask import request from flask import request
config = ConfigParser() config = ConfigParser()
config.read('./config.ini') config.read('./config.ini')
def is_mobile_request(user_agent: str) -> bool: def is_mobile_request(user_agent: str) -> bool:
""" """
判断是否是移动端 判断是否是移动端
@ -16,6 +16,7 @@ def is_mobile_request(user_agent: str) -> bool:
ua_expression = config.get('Settings', 'UA_EXPRESSION') ua_expression = config.get('Settings', 'UA_EXPRESSION')
return bool(eval(ua_expression, {"user_agent": user_agent, "re": re})) return bool(eval(ua_expression, {"user_agent": user_agent, "re": re}))
def get_user() -> str: def get_user() -> str:
""" """
根据访问IP决定用户ID 根据访问IP决定用户ID