From f86d5b80d8f204e9087b2377b0a1b4bd71ca1d14 Mon Sep 17 00:00:00 2001 From: NY Date: Wed, 12 Mar 2025 17:43:24 +0800 Subject: [PATCH] fix --- pkg/dash/func/info.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/dash/func/info.py b/pkg/dash/func/info.py index 44d1e6b..28a3c4a 100644 --- a/pkg/dash/func/info.py +++ b/pkg/dash/func/info.py @@ -24,7 +24,7 @@ def update_info(n, target_value): table_style_l = {'textAlign': 'left'} target = int(target_value) if target_value is not None else None - avg_tweets_per_day = calculate_avg_tweets_per_day(target, now, remain_hours) if target is not None else "未计算" + avg_tweets_per_day = calculate_avg_tweets_per_day(target, now, remain_hours) if target is not None else "TBD" days_passed = 7 - days_to_next_friday avg_tweets = round(tweet_count / days_passed, 2) if days_passed > 0 else 0 @@ -66,7 +66,7 @@ def update_info(n, target_value): style=table_style_l) ]), html.Tr([ - html.Td(f"Target: {target if target else '[未设置]'}", + html.Td(f"Target: {target if target else '[TBD]'}", colSpan=4, style=table_style_c), html.Td(f"Need's Avg Tweets Per Day: {avg_tweets_per_day}", @@ -77,7 +77,7 @@ def update_info(n, target_value): html.Td(f"Avg Tweets: {avg_tweets}", colSpan=4, style=table_style_c), - html.Td("", # 右侧留空,与上一行对齐 + html.Td("", colSpan=4, style=table_style_l) ]) @@ -135,9 +135,9 @@ def calculate_pace_increase_in_hour(): def calculate_avg_tweets_per_day(target, now, remain): Xi = get_hourly_weighted_array() if remain <= 0: - return "剩余时间不足,无法计算" + return "remain<=0" if target <= now: - return "目标已达成,无需额外发帖" + return "Already reach" fx = max(remain - 12, 0) @@ -147,12 +147,10 @@ def calculate_avg_tweets_per_day(target, now, remain): full_hours = int(remain) fractional_hour = remain - full_hours if full_hours >= 24: - print(f"Debug: full_hours={full_hours} exceeds 24, capping at 23") full_hours = 23 - fractional_hour = 0 # 如果超过24小时,小数部分忽略 + fractional_hour = 0 if full_hours < 0: - print(f"Debug: full_hours={full_hours} is negative, setting to 0") full_hours = 0 if full_hours > 0: @@ -162,8 +160,7 @@ def calculate_avg_tweets_per_day(target, now, remain): fy *= 24 if fx + fy == 0: - return "计算无效,请检查剩余时间" + return "fx + fy = 0" result = (target - now) / ((fx + fy) / 24) - print(f"Debug: fx={fx}, fy={fy}, result={result}") return round(result, 2) \ No newline at end of file