Skip to content

Commit

Permalink
feat: Updated agents-api/agents_api/models/user/li
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 e06e7ac
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions agents-api/agents_api/models/user/list_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,28 @@ def list_users_query(
metadata_filter: dict[str, Any] = {},
client: CozoClient = client,
) -> pd.DataFrame:
"""
Queries the 'cozodb' database to list users associated with a specific developer.
Parameters:
- developer_id (UUID): The unique identifier of the developer.
- limit (int): The maximum number of users to return. Defaults to 100.
- offset (int): The number of users to skip before starting to collect the result set. Defaults to 0.
- metadata_filter (dict[str, Any]): A dictionary representing filters to apply on user metadata.
- client (CozoClient): The database client used to run the query. Defaults to an instance of CozoClient.
Returns:
- pd.DataFrame: A DataFrame containing the queried user data.
"""
# Construct a filter string for the metadata based on the provided dictionary.
metadata_filter_str = ", ".join(
[
f"metadata->{json.dumps(k)} == {json.dumps(v)}"
for k, v in metadata_filter.items()
]
)

# Define the datalog query for retrieving user information based on the specified filters and sorting them by creation date in descending order.
query = f"""
input[developer_id] <- [[to_uuid($developer_id)]]
Expand Down Expand Up @@ -51,6 +66,7 @@ def list_users_query(
:sort -created_at
"""

# Execute the datalog query with the specified parameters and return the results as a DataFrame.
return client.run(
query, {"developer_id": str(developer_id), "limit": limit, "offset": offset}
)

0 comments on commit e06e7ac

Please sign in to comment.