Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,8 +5,6 @@ import logging
|
|
5 |
import matplotlib
|
6 |
matplotlib.use('Agg') # Set backend for Matplotlib to avoid GUI conflicts with Gradio
|
7 |
import matplotlib.pyplot as plt
|
8 |
-
# No longer need timedelta here if all date logic is in analytics_data_processing
|
9 |
-
# from datetime import datetime, timedelta
|
10 |
|
11 |
# --- Module Imports ---
|
12 |
from gradio_utils import get_url_user_token
|
@@ -24,7 +22,6 @@ from ui_generators import (
|
|
24 |
run_follower_stats_tab_display
|
25 |
)
|
26 |
import analytics_plot_generators
|
27 |
-
# NEW: Import for data processing functions
|
28 |
import analytics_data_processing
|
29 |
|
30 |
# Configure logging
|
@@ -157,13 +154,16 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|
|
157 |
label="Select Date Range (for Posts & Mentions)",
|
158 |
value="Last 30 Days"
|
159 |
)
|
160 |
-
|
161 |
-
|
|
|
162 |
|
163 |
apply_filter_btn = gr.Button("🔍 Apply Filter & Refresh Analytics", variant="primary")
|
164 |
|
165 |
def toggle_custom_date_pickers(selection):
|
166 |
-
|
|
|
|
|
167 |
|
168 |
date_filter_selector.change(
|
169 |
fn=toggle_custom_date_pickers,
|
|
|
5 |
import matplotlib
|
6 |
matplotlib.use('Agg') # Set backend for Matplotlib to avoid GUI conflicts with Gradio
|
7 |
import matplotlib.pyplot as plt
|
|
|
|
|
8 |
|
9 |
# --- Module Imports ---
|
10 |
from gradio_utils import get_url_user_token
|
|
|
22 |
run_follower_stats_tab_display
|
23 |
)
|
24 |
import analytics_plot_generators
|
|
|
25 |
import analytics_data_processing
|
26 |
|
27 |
# Configure logging
|
|
|
154 |
label="Select Date Range (for Posts & Mentions)",
|
155 |
value="Last 30 Days"
|
156 |
)
|
157 |
+
# Corrected to gr.DateTime
|
158 |
+
custom_start_date_picker = gr.DateTime(label="Start Date (Custom)", visible=False, include_time=False, type="string")
|
159 |
+
custom_end_date_picker = gr.DateTime(label="End Date (Custom)", visible=False, include_time=False, type="string")
|
160 |
|
161 |
apply_filter_btn = gr.Button("🔍 Apply Filter & Refresh Analytics", variant="primary")
|
162 |
|
163 |
def toggle_custom_date_pickers(selection):
|
164 |
+
is_custom = selection == "Custom Range"
|
165 |
+
return gr.update(visible=is_custom), gr.update(visible=is_custom)
|
166 |
+
|
167 |
|
168 |
date_filter_selector.change(
|
169 |
fn=toggle_custom_date_pickers,
|