From 4b5685f08c2606412eaed69415702114d7e0852d Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 1 Dec 2024 11:35:31 +0200 Subject: [PATCH 1/2] fixed issue 317 --- src/sempy_labs/admin/_basic_functions.py | 30 +++++------------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/sempy_labs/admin/_basic_functions.py b/src/sempy_labs/admin/_basic_functions.py index 9b63f67..230343b 100644 --- a/src/sempy_labs/admin/_basic_functions.py +++ b/src/sempy_labs/admin/_basic_functions.py @@ -782,34 +782,18 @@ def list_activity_events( ) resposeJson = {"activityEventEntities": []} - - tic = "%27" - space = "%20" client = fabric.PowerBIRestClient() - params = {} - url = "/v1.0/myorg/admin/activityevents" - - if start_dt is not None: - params["startDateTime"] = f"'{start_dt.isoformat(timespec='milliseconds')}'" - - if end_dt is not None: - params["endDateTime"] = f"'{end_dt.isoformat(timespec='milliseconds')}'" + url = f"/v1.0/myorg/admin/activityevents?startDateTime='{start_time}'&endDateTime='{end_time}'" conditions = [] - if activity_filter is not None: - conditions.append(f"Activity{space}eq{space}{tic}{activity_filter}{tic}") - + conditions.append(f"Activity eq '{activity_filter}'") if user_id_filter is not None: - conditions.append(f"UserId{space}eq{space}{tic}{user_id_filter}{tic}") + conditions.append(f"UserId eq '{user_id_filter}'") if conditions: - params["filder"] = f"{f'{space}and{space}'.join(conditions)}" - - url_parts = list(urllib.parse.urlparse(url)) - url_parts[4] = urllib.parse.urlencode(params) - url = urllib.parse.urlunparse(url_parts) + url += f"&$filter={f' and '.join(conditions)}" response = client.get(url) @@ -853,11 +837,9 @@ def list_activity_events( if return_dataframe: df["Creation Time"] = pd.to_datetime(df["Creation Time"]) - activity_events = df + return df else: - activity_events = resposeJson - - return activity_events + return resposeJson def _resolve_capacity_name_and_id( From 7975dd46a69fe8b24a4b2c1ab39f3ed7a90864de Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 2 Dec 2024 12:17:22 +0200 Subject: [PATCH 2/2] fixed per comment --- src/sempy_labs/_model_dependencies.py | 5 ++++- src/sempy_labs/admin/_basic_functions.py | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/sempy_labs/_model_dependencies.py b/src/sempy_labs/_model_dependencies.py index b90c904..6b63282 100644 --- a/src/sempy_labs/_model_dependencies.py +++ b/src/sempy_labs/_model_dependencies.py @@ -199,7 +199,10 @@ def get_model_calc_dependencies( for _, row in incomplete_rows.iterrows(): referenced_full_name = row["Referenced Full Object Name"] referenced_object_type = row["Referenced Object Type"] - dep_filt = dep[(dep["Full Object Name"] == referenced_full_name) & (dep["Object Type"] == referenced_object_type)] + dep_filt = dep[ + (dep["Full Object Name"] == referenced_full_name) + & (dep["Object Type"] == referenced_object_type) + ] # Expand dependencies and update 'Done' status as needed new_rows = [] for _, dependency in dep_filt.iterrows(): diff --git a/src/sempy_labs/admin/_basic_functions.py b/src/sempy_labs/admin/_basic_functions.py index 230343b..d20e96c 100644 --- a/src/sempy_labs/admin/_basic_functions.py +++ b/src/sempy_labs/admin/_basic_functions.py @@ -781,9 +781,8 @@ def list_activity_events( ] ) - resposeJson = {"activityEventEntities": []} + response_json = {"activityEventEntities": []} client = fabric.PowerBIRestClient() - url = f"/v1.0/myorg/admin/activityevents?startDateTime='{start_time}'&endDateTime='{end_time}'" conditions = [] @@ -833,13 +832,15 @@ def list_activity_events( ignore_index=True, ) else: - resposeJson["activityEventEntities"].extend(r.get("activityEventEntities")) + response_json["activityEventEntities"].extend( + r.get("activityEventEntities") + ) if return_dataframe: df["Creation Time"] = pd.to_datetime(df["Creation Time"]) return df else: - return resposeJson + return response_json def _resolve_capacity_name_and_id(