Skip to content

Commit

Permalink
Merge pull request #53 from DostEducation/develop
Browse files Browse the repository at this point in the history
Release 28 May 2024
  • Loading branch information
Sachinbisht27 authored May 28, 2024
2 parents 6eff155 + a688bf3 commit 1693828
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions api/helpers/common_helper.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
from datetime import datetime, timezone
from typing import Any


def get_current_utc_timestamp() -> datetime:
return datetime.now(timezone.utc)


def check_activity_key(
activity_key: str, activity_value: dict[str, Any], keyword: str, status: str
activity_key: str, activity_value: str, keyword: str, status: str
):
return (
True
if activity_key.startswith(keyword)
and activity_key.endswith(status)
and activity_value["value"] == "yes"
and activity_value == "yes"
else False
)
6 changes: 3 additions & 3 deletions api/services/user_activities_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ def __init__(self, user, user_flow):
def handle_user_activities(self, json_data: dict[str, Any]):
try:
current_time = common_helper.get_current_utc_timestamp()
contact_activities = json_data.get("contact", {}).get("fields", {})

for activity_key, activity_value in contact_activities.items():
for activity_key, activity_value in json_data.items():
user_activity = self.create_or_update_user_activity(
activity_key, activity_value, current_time
)
Expand All @@ -34,7 +33,7 @@ def handle_user_activities(self, json_data: dict[str, Any]):
)

def create_or_update_user_activity(
self, activity_key: str, activity_value: dict[str, Any], current_time: datetime
self, activity_key: str, activity_value: str, current_time: datetime
) -> Optional[models.UserActivities]:
is_started = common_helper.check_activity_key(
activity_key, activity_value, "activity_", "_started"
Expand Down Expand Up @@ -65,6 +64,7 @@ def create_activity(
activity=activity_key.strip(),
is_started=True,
started_on=current_time,
is_succeeded=False,
)

def update_succeeded_activity(
Expand Down

0 comments on commit 1693828

Please sign in to comment.