fix
This commit is contained in:
parent
d58ee2936c
commit
f86d5b80d8
@ -24,7 +24,7 @@ def update_info(n, target_value):
|
|||||||
table_style_l = {'textAlign': 'left'}
|
table_style_l = {'textAlign': 'left'}
|
||||||
|
|
||||||
target = int(target_value) if target_value is not None else None
|
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
|
days_passed = 7 - days_to_next_friday
|
||||||
avg_tweets = round(tweet_count / days_passed, 2) if days_passed > 0 else 0
|
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)
|
style=table_style_l)
|
||||||
]),
|
]),
|
||||||
html.Tr([
|
html.Tr([
|
||||||
html.Td(f"Target: {target if target else '[未设置]'}",
|
html.Td(f"Target: {target if target else '[TBD]'}",
|
||||||
colSpan=4,
|
colSpan=4,
|
||||||
style=table_style_c),
|
style=table_style_c),
|
||||||
html.Td(f"Need's Avg Tweets Per Day: {avg_tweets_per_day}",
|
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}",
|
html.Td(f"Avg Tweets: {avg_tweets}",
|
||||||
colSpan=4,
|
colSpan=4,
|
||||||
style=table_style_c),
|
style=table_style_c),
|
||||||
html.Td("", # 右侧留空,与上一行对齐
|
html.Td("",
|
||||||
colSpan=4,
|
colSpan=4,
|
||||||
style=table_style_l)
|
style=table_style_l)
|
||||||
])
|
])
|
||||||
@ -135,9 +135,9 @@ def calculate_pace_increase_in_hour():
|
|||||||
def calculate_avg_tweets_per_day(target, now, remain):
|
def calculate_avg_tweets_per_day(target, now, remain):
|
||||||
Xi = get_hourly_weighted_array()
|
Xi = get_hourly_weighted_array()
|
||||||
if remain <= 0:
|
if remain <= 0:
|
||||||
return "剩余时间不足,无法计算"
|
return "remain<=0"
|
||||||
if target <= now:
|
if target <= now:
|
||||||
return "目标已达成,无需额外发帖"
|
return "Already reach"
|
||||||
|
|
||||||
fx = max(remain - 12, 0)
|
fx = max(remain - 12, 0)
|
||||||
|
|
||||||
@ -147,12 +147,10 @@ def calculate_avg_tweets_per_day(target, now, remain):
|
|||||||
full_hours = int(remain)
|
full_hours = int(remain)
|
||||||
fractional_hour = remain - full_hours
|
fractional_hour = remain - full_hours
|
||||||
if full_hours >= 24:
|
if full_hours >= 24:
|
||||||
print(f"Debug: full_hours={full_hours} exceeds 24, capping at 23")
|
|
||||||
full_hours = 23
|
full_hours = 23
|
||||||
fractional_hour = 0 # 如果超过24小时,小数部分忽略
|
fractional_hour = 0
|
||||||
|
|
||||||
if full_hours < 0:
|
if full_hours < 0:
|
||||||
print(f"Debug: full_hours={full_hours} is negative, setting to 0")
|
|
||||||
full_hours = 0
|
full_hours = 0
|
||||||
|
|
||||||
if full_hours > 0:
|
if full_hours > 0:
|
||||||
@ -162,8 +160,7 @@ def calculate_avg_tweets_per_day(target, now, remain):
|
|||||||
fy *= 24
|
fy *= 24
|
||||||
|
|
||||||
if fx + fy == 0:
|
if fx + fy == 0:
|
||||||
return "计算无效,请检查剩余时间"
|
return "fx + fy = 0"
|
||||||
|
|
||||||
result = (target - now) / ((fx + fy) / 24)
|
result = (target - now) / ((fx + fy) / 24)
|
||||||
print(f"Debug: fx={fx}, fy={fy}, result={result}")
|
|
||||||
return round(result, 2)
|
return round(result, 2)
|
Loading…
x
Reference in New Issue
Block a user