diff --git a/pkg/dash/app_html.py b/pkg/dash/app_html.py
index c0f0ea5..df8f2b6 100644
--- a/pkg/dash/app_html.py
+++ b/pkg/dash/app_html.py
@@ -92,6 +92,7 @@ def layout_config(app):
),
html.A(
href='https://x.com/elonmusk',
+ target='_blank',
children=[
html.Img(
src='https://pbs.twimg.com/profile_images/1893803697185910784/Na5lOWi5_400x400.jpg',
diff --git a/pkg/dash/func/info.py b/pkg/dash/func/info.py
index 2940791..949d46b 100644
--- a/pkg/dash/func/info.py
+++ b/pkg/dash/func/info.py
@@ -1,5 +1,5 @@
import pytz
-from pkg.tool import get_tweets_since_last_friday,format_time_str
+from pkg.tool import get_tweets_since_last_friday, format_time_str, get_time_since_last_tweet
from pkg.dash.app_init import app
from dash.dependencies import Input, Output
from datetime import timedelta
@@ -18,7 +18,8 @@ def update_info(n):
pace_increases = calculate_pace_increase_in_hour()
_, days_to_next_friday = get_pace_params()
table_style_border = {'textAlign': 'center', 'border': '1px solid white'}
- table_style = {'textAlign': 'center'}
+ table_style_c = {'textAlign': 'center'}
+ table_style_l = {'textAlign': 'left'}
# First table for Pace
pace_table_rows = [
@@ -43,9 +44,20 @@ def update_info(n):
html.Td(f"{pace_increases['increase_30']:.2f}", style=table_style_border)
]),
html.Tr([
- html.Td(f"Remain: {format_time_str(days_to_next_friday)}",
- colSpan=8,
- style=table_style)
+ html.Td(f"Remain",
+ colSpan=4,
+ style=table_style_c),
+ html.Td(format_time_str(days_to_next_friday),
+ colSpan=4,
+ style=table_style_l)
+ ]),
+ html.Tr([
+ html.Td(f"Last Tweet",
+ colSpan=4,
+ style=table_style_c),
+ html.Td(format_time_str(get_time_since_last_tweet()),
+ colSpan=4,
+ style=table_style_l)
])
]
pace_table = html.Table(pace_table_rows, style={
diff --git a/pkg/tool.py b/pkg/tool.py
index e526478..bcc8eb7 100644
--- a/pkg/tool.py
+++ b/pkg/tool.py
@@ -71,6 +71,22 @@ def get_tweets_since_last_friday():
return int(tweet_count)
return 0
+
+def get_time_since_last_tweet():
+ est = pytz.timezone('US/Eastern')
+ now_est = datetime.now(est)
+ if (not hasattr(render_data, 'global_df') or
+ render_data.global_df is None or
+ render_data.global_df.empty):
+ return 0.0
+ df = render_data.global_df
+ if 'datetime_est' not in df.columns:
+ return 0.0
+ latest_tweet_time = df['datetime_est'].max()
+ time_diff = now_est - latest_tweet_time
+ days_diff = time_diff.total_seconds() / (24 * 60 * 60) # 转换为天数
+ return days_diff
+
def format_time_str(days_to_next_friday):
total_seconds = days_to_next_friday * 24 * 60 * 60
days = int(total_seconds // (24 * 60 * 60))
@@ -78,4 +94,4 @@ def format_time_str(days_to_next_friday):
minutes = int((total_seconds % (60 * 60)) // 60)
seconds = int(total_seconds % 60)
total_hours = round(days_to_next_friday * 24, 2)
- return f"{days}d {hours}h {minutes:02d}m {seconds:02d}s ({total_hours}h)"
\ No newline at end of file
+ return f"{days}d {hours:02d}h {minutes:02d}m {seconds:02d}s ({total_hours}h)"
\ No newline at end of file