Skip to content

Commit

Permalink
feat: Updated agents-api/agents_api/models/user/pa
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Apr 13, 2024
1 parent ebd1b1e commit 59ccb2e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions agents-api/agents_api/models/user/patch_user.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Module for generating datalog queries to update user information in the 'cozodb' database."""

from uuid import UUID

import pandas as pd
Expand All @@ -7,7 +9,19 @@
from ...common.utils.datetime import utcnow


"""
Generates a datalog query for updating a user's information.
Parameters:
- developer_id (UUID): The UUID of the developer.
- user_id (UUID): The UUID of the user to be updated.
- **update_data: Arbitrary keyword arguments representing the data to be updated.
Returns:
- pd.DataFrame: A pandas DataFrame containing the results of the query execution.
"""
def patch_user_query(developer_id: UUID, user_id: UUID, **update_data) -> pd.DataFrame:
# Prepare data for mutation by filtering out None values and adding system-generated fields.
user_update_cols, user_update_vals = cozo_process_mutate_data(
{
**{k: v for k, v in update_data.items() if v is not None},
Expand All @@ -17,6 +31,7 @@ def patch_user_query(developer_id: UUID, user_id: UUID, **update_data) -> pd.Dat
}
)

# Construct the datalog query for updating user information.
query = f"""
# update the user
?[{user_update_cols}] <- $user_update_vals
Expand Down

0 comments on commit 59ccb2e

Please sign in to comment.