From 23f9e73f19af1dbd582c69739b1495adb5f2b63f Mon Sep 17 00:00:00 2001 From: Alexander Metzger Date: Tue, 6 Feb 2024 21:41:34 -0800 Subject: [PATCH 1/2] temporarily hide response time --- bots/models.py | 7 ++----- recipes/VideoBotsStats.py | 27 --------------------------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/bots/models.py b/bots/models.py index e2c66148a..3a440ab73 100644 --- a/bots/models.py +++ b/bots/models.py @@ -935,10 +935,7 @@ def to_df_format( else None ), # only show first feedback as per Sean's request "Analysis JSON": message.analysis_result, - "Response Time": ( - message.response_time - and round(message.response_time.total_seconds(), 1) - ), + "Run Time": message.saved_run.run_time if message.saved_run else 0, # user messages have no run/run_time } rows.append(row) df = pd.DataFrame.from_records( @@ -950,7 +947,7 @@ def to_df_format( "Sent", "Feedback", "Analysis JSON", - "Response Time", + "Run Time", ], ) return df diff --git a/recipes/VideoBotsStats.py b/recipes/VideoBotsStats.py index 00c7f07dd..e7fea6c12 100644 --- a/recipes/VideoBotsStats.py +++ b/recipes/VideoBotsStats.py @@ -439,8 +439,6 @@ def calculate_stats_binned_by_time( ) ) .annotate(Average_runtime=Avg("saved_run__run_time")) - .annotate(Average_response_time=Avg("response_time")) - .annotate(Average_analysis_time=Avg("analysis_run__run_time")) .annotate(Unique_feedback_givers=Count("feedbacks", distinct=True)) .values( "date", @@ -448,9 +446,7 @@ def calculate_stats_binned_by_time( "Convos", "Senders", "Unique_feedback_givers", - "Average_response_time", "Average_runtime", - "Average_analysis_time", ) ) @@ -504,9 +500,7 @@ def calculate_stats_binned_by_time( "Convos", "Senders", "Unique_feedback_givers", - "Average_response_time", "Average_runtime", - "Average_analysis_time", ], ) df = df.merge( @@ -546,11 +540,6 @@ def calculate_stats_binned_by_time( ) * 100 df["Msgs_per_convo"] = df["Messages_Sent"] / df["Convos"] df["Msgs_per_user"] = df["Messages_Sent"] / df["Senders"] - try: - df["Average_response_time"] = df["Average_response_time"].dt.total_seconds() - except AttributeError: - pass - df["Average_response_time"] = df["Average_response_time"] * factor df.fillna(0, inplace=True) df = df.round(0).astype("int32", errors="ignore") return df @@ -699,14 +688,6 @@ def plot_graphs(self, view, df): st.write("---") fig = go.Figure( data=[ - go.Scatter( - name="Average Response Time", - mode="lines+markers", - x=list(df["date"]), - y=list(df["Average_response_time"]), - text=list(df["Average_response_time"]), - hovertemplate="Average Response Time: %{y:.0f}", - ), go.Scatter( name="Average Run Time", mode="lines+markers", @@ -715,14 +696,6 @@ def plot_graphs(self, view, df): text=list(df["Average_runtime"]), hovertemplate="Average Runtime: %{y:.0f}", ), - go.Scatter( - name="Average Analysis Time", - mode="lines+markers", - x=list(df["date"]), - y=list(df["Average_analysis_time"]), - text=list(df["Average_analysis_time"]), - hovertemplate="Average Analysis Time: %{y:.0f}", - ), ], layout=dict( margin=dict(l=0, r=0, t=28, b=0), From caf62278c885030706652da727ba24bb7b0b4648 Mon Sep 17 00:00:00 2001 From: Alexander Metzger Date: Sat, 10 Feb 2024 16:55:07 -0800 Subject: [PATCH 2/2] default statspage to last 15 days in daily view --- recipes/VideoBotsStats.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/recipes/VideoBotsStats.py b/recipes/VideoBotsStats.py index e7fea6c12..a8fd4e541 100644 --- a/recipes/VideoBotsStats.py +++ b/recipes/VideoBotsStats.py @@ -291,15 +291,16 @@ def render_date_view_inputs(self, bi): start_date = bi.created_at end_date = timezone.now() else: - start_of_year_date = timezone.now().replace(month=1, day=1) + fifteen_days_ago = timezone.now() - timedelta(days=15) + fifteen_days_ago = fifteen_days_ago.replace(hour=0, minute=0, second=0) st.session_state.setdefault( "start_date", self.request.query_params.get( - "start_date", start_of_year_date.strftime("%Y-%m-%d") + "start_date", fifteen_days_ago.strftime("%Y-%m-%d") ), ) start_date: datetime = ( - st.date_input("Start date", key="start_date") or start_of_year_date + st.date_input("Start date", key="start_date") or fifteen_days_ago ) st.session_state.setdefault( "end_date", @@ -311,7 +312,7 @@ def render_date_view_inputs(self, bi): st.date_input("End date", key="end_date") or timezone.now() ) st.session_state.setdefault( - "view", self.request.query_params.get("view", "Weekly") + "view", self.request.query_params.get("view", "Daily") ) st.write("---") view = st.horizontal_radio(