Skip to content

Commit

Permalink
change datetime imports in backgorund
Browse files Browse the repository at this point in the history
  • Loading branch information
KellyRousselHoomano committed Jun 27, 2024
1 parent f308789 commit 6f08221
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions background/app/models/cortex/extract_todos_cortex.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from datetime import datetime


import requests
from app import db, language_retriever, conversation_retriever
Expand All @@ -12,7 +12,7 @@

from models.todos.todos_creator import TodosCreator
from sqlalchemy import func

from datetime import datetime

class ExtractTodosCortex:
logger_prefix = "ExtractTodosCortex"
Expand Down
6 changes: 3 additions & 3 deletions background/app/models/cortex/reschedule_todo_cortex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime


from app import db, language_retriever, conversation_retriever
from mojodex_core.entities.db_base_entities import *
Expand All @@ -12,7 +12,7 @@
from models.todos.todos_rescheduler import TodosRescheduler

from mojodex_core.mail import send_technical_error_email

from datetime import datetime, timezone

class RescheduleTodoCortex:
logger_prefix = "RescheduleTodoCortex"
Expand Down Expand Up @@ -124,7 +124,7 @@ def __get_todolist(self, user_id):
.group_by(MdTodoScheduling.todo_fk) \
.subquery()
# Get the current date in UTC
now_utc = datetime.utcnow().date()
now_utc = datetime.now(timezone.utc).date()
results = db.session.query(MdTodo.description, latest_todo_scheduling.c.latest_scheduled_date) \
.join(MdUserTaskExecution, MdTodo.user_task_execution_fk == MdUserTaskExecution.user_task_execution_pk) \
.join(latest_todo_scheduling, MdTodo.todo_pk == latest_todo_scheduling.c.todo_fk) \
Expand Down
6 changes: 3 additions & 3 deletions background/app/models/knowledge/knowledge_collector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone

from mojodex_core.logging_handler import MojodexCoreLogger

Expand Down Expand Up @@ -26,7 +26,7 @@ def get_mojo_knowledge():
def get_global_context_knowledge(timezone_offset=0):
"""Returns the global context knowledge for the current time
:param timezone_offset: offset in minutes to remove from UTC time to get user time"""
timestamp = datetime.utcnow()
timestamp = datetime.now(timezone.utc)
timestamp -= timedelta(minutes=timezone_offset)
global_context = MPT("mojodex_core/instructions/global_context.mpt",
weekday=timestamp.strftime("%A"),
Expand All @@ -41,7 +41,7 @@ def mojodex_knowledge(self):
@property
def localized_context(self):
try:
timestamp = datetime.utcnow()
timestamp = datetime.now(timezone.utc)
if self.user_timezone_offset:
timestamp -= timedelta(minutes=self.user_timezone_offset)
return MPT("mojodex_core/instructions/global_context.mpt",
Expand Down
1 change: 0 additions & 1 deletion background/app/routes/event_generation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from flask import request
from flask_restful import Resource
from app import db, executor
from mojodex_core.entities.db_base_entities import *

from models.events.daily_notifications_generator import DailyNotificationsGenerator
from models.events.daily_emails_generator import DailyEmailsGenerator
Expand Down

0 comments on commit 6f08221

Please sign in to comment.