From 59ccb2ed1717dc52f89efcb912569d9d67737422 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sat, 13 Apr 2024 12:59:51 +0000 Subject: [PATCH] feat: Updated agents-api/agents_api/models/user/pa --- agents-api/agents_api/models/user/patch_user.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/agents-api/agents_api/models/user/patch_user.py b/agents-api/agents_api/models/user/patch_user.py index 53a207e3..c8dfe09a 100644 --- a/agents-api/agents_api/models/user/patch_user.py +++ b/agents-api/agents_api/models/user/patch_user.py @@ -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 @@ -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}, @@ -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