From b063439037904c706e4101db916f1b68e9fbc366 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Mon, 5 Feb 2024 20:42:30 +0530 Subject: [PATCH] make response_time null by default --- bots/migrations/0056_message_response_time.py | 19 --------------- .../0057_message_response_time_and_more.py | 23 +++++++++++++++++++ bots/models.py | 8 +++++-- 3 files changed, 29 insertions(+), 21 deletions(-) delete mode 100644 bots/migrations/0056_message_response_time.py create mode 100644 bots/migrations/0057_message_response_time_and_more.py diff --git a/bots/migrations/0056_message_response_time.py b/bots/migrations/0056_message_response_time.py deleted file mode 100644 index 06730e931..000000000 --- a/bots/migrations/0056_message_response_time.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 4.2.7 on 2024-02-01 20:15 - -import datetime -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('bots', '0055_workflowmetadata'), - ] - - operations = [ - migrations.AddField( - model_name='message', - name='response_time', - field=models.DurationField(default=datetime.timedelta(days=-1, seconds=86399), help_text='The time it took for the bot to respond to the corresponding user message'), - ), - ] diff --git a/bots/migrations/0057_message_response_time_and_more.py b/bots/migrations/0057_message_response_time_and_more.py new file mode 100644 index 000000000..5bdecd39c --- /dev/null +++ b/bots/migrations/0057_message_response_time_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.7 on 2024-02-05 15:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bots', '0056_botintegration_streaming_enabled'), + ] + + operations = [ + migrations.AddField( + model_name='message', + name='response_time', + field=models.DurationField(default=None, help_text='The time it took for the bot to respond to the corresponding user message', null=True), + ), + migrations.AlterField( + model_name='botintegration', + name='streaming_enabled', + field=models.BooleanField(default=False, help_text='If set, the bot will stream messages to the frontend (Slack only)'), + ), + ] diff --git a/bots/models.py b/bots/models.py index 4aa2c3d4a..8e2a41dc8 100644 --- a/bots/models.py +++ b/bots/models.py @@ -932,7 +932,10 @@ def to_df_format( else None ), # only show first feedback as per Sean's request "Analysis JSON": message.analysis_result, - "Response Time": round(message.response_time.total_seconds(), 1), + "Response Time": ( + message.response_time + and round(message.response_time.total_seconds(), 1) + ), } rows.append(row) df = pd.DataFrame.from_records( @@ -1054,7 +1057,8 @@ class Message(models.Model): ) response_time = models.DurationField( - default=datetime.timedelta(seconds=-1), + default=None, + null=True, help_text="The time it took for the bot to respond to the corresponding user message", )