Skip to content

Commit

Permalink
use timezone.now()
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy committed Feb 5, 2024
1 parent 121fab3 commit d2da2d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 5 additions & 8 deletions daras_ai_v2/bots.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import mimetypes
import traceback
import typing
from datetime import datetime
from urllib.parse import parse_qs

import pytz
from datetime import datetime
from django.db import transaction
from django.utils import timezone
from fastapi import HTTPException, Request
from furl import furl
from sentry_sdk import capture_exception

from daras_ai_v2 import settings
from app_users.models import AppUser
from bots.models import (
Platform,
Expand Down Expand Up @@ -191,7 +190,7 @@ def _on_msg(bot: BotInterface):
speech_run = None
input_images = None
input_documents = None
recieved_time: datetime = datetime.now(tz=pytz.timezone(settings.TIME_ZONE))
recieved_time: datetime = timezone.now()
if not bot.page_cls:
bot.send_msg(text=PAGE_NOT_CONNECTED_ERROR)
return
Expand Down Expand Up @@ -463,8 +462,7 @@ def _save_msgs(
if speech_run
else None
),
response_time=datetime.now(tz=pytz.timezone(settings.TIME_ZONE))
- received_time,
response_time=timezone.now() - received_time,
)
attachments = []
for f_url in (input_images or []) + (input_documents or []):
Expand All @@ -481,8 +479,7 @@ def _save_msgs(
saved_run=SavedRun.objects.get_or_create(
workflow=Workflow.VIDEO_BOTS, **furl(url).query.params
)[0],
response_time=datetime.now(tz=pytz.timezone(settings.TIME_ZONE))
- received_time,
response_time=timezone.now() - received_time,
)
# save the messages & attachments
with transaction.atomic():
Expand Down
6 changes: 3 additions & 3 deletions recipes/VideoBots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,9 +1124,9 @@ def slack_specific_settings(self, bi: BotIntegration):
st.session_state[f"_bi_name_{bi.id}"] = (
pr and pr.title
) or self.get_recipe_title()
st.session_state[f"_bi_slack_read_receipt_msg_{bi.id}"] = (
BotIntegration._meta.get_field("slack_read_receipt_msg").default
)
st.session_state[
f"_bi_slack_read_receipt_msg_{bi.id}"
] = BotIntegration._meta.get_field("slack_read_receipt_msg").default

bi.slack_read_receipt_msg = st.text_input(
"""
Expand Down

0 comments on commit d2da2d1

Please sign in to comment.