Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 18 July 2024 #67

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions api/helpers/common_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ def get_current_utc_timestamp() -> datetime:
return datetime.now(timezone.utc)


def check_activity_key(
activity_key: str, activity_value: str, keyword: str, status: str
):
def validate_activity_status(activity_key: str, keyword: str, status: str):
return (
True
if activity_key.startswith(keyword)
and activity_key.endswith(status)
and activity_value == "yes"
if activity_key.startswith(keyword) and activity_key.endswith(status)
else False
)
7 changes: 6 additions & 1 deletion api/services/flow_run_log_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ def create_user_flow_log(self, json_data: dict[str, Any]) -> models.UserFlows:
)
)

if flow_status == self.class_model.FlowRunStatus.SENT:
if flow_status == self.class_model.FlowRunStatus.SENT or (
flow_status == self.class_model.FlowRunStatus.COMPLETED
and latest_flow_log is None
):
user_flow_log = self.create_log(flow_uuid, flow_name, flow_type)
elif flow_status == self.class_model.FlowRunStatus.COMPLETED:
user_flow_log = self.update_log(latest_flow_log)
else:
user_flow_log = latest_flow_log

except Exception as e:
logger.error(
Expand Down
18 changes: 9 additions & 9 deletions api/services/user_activities_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def handle_user_activities(self, json_data: dict[str, Any]):
try:
current_time = common_helper.get_current_utc_timestamp()

for activity_key, activity_value in json_data.items():
for activity_key, _ in json_data.items():
user_activity = self.create_or_update_user_activity(
activity_key, activity_value, current_time
activity_key, current_time
)
if user_activity:
db.session.add(user_activity)
Expand All @@ -33,16 +33,16 @@ def handle_user_activities(self, json_data: dict[str, Any]):
)

def create_or_update_user_activity(
self, activity_key: str, activity_value: str, current_time: datetime
self, activity_key: str, current_time: datetime
) -> Optional[models.UserActivities]:
is_started = common_helper.check_activity_key(
activity_key, activity_value, "activity_", "_started"
is_started = common_helper.validate_activity_status(
activity_key, "activity_", "_started"
)
is_succeeded = common_helper.check_activity_key(
activity_key, activity_value, "activity_", "_success"
is_succeeded = common_helper.validate_activity_status(
activity_key, "activity_", "_success"
)
is_completed = common_helper.check_activity_key(
activity_key, activity_value, "activity_", "_completed"
is_completed = common_helper.validate_activity_status(
activity_key, "activity_", "_completed"
)

if is_started:
Expand Down
Loading