Skip to content

Commit

Permalink
Merge branch 'm-kovalsky/issue317'
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kovalsky committed Dec 2, 2024
2 parents c0786ee + 7975dd4 commit ebd7b84
Showing 1 changed file with 10 additions and 27 deletions.
37 changes: 10 additions & 27 deletions src/sempy_labs/admin/_basic_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,35 +781,18 @@ def list_activity_events(
]
)

resposeJson = {"activityEventEntities": []}

tic = "%27"
space = "%20"
response_json = {"activityEventEntities": []}
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)

Expand Down Expand Up @@ -849,15 +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"])
activity_events = df
return df
else:
activity_events = resposeJson

return activity_events
return response_json


def _resolve_capacity_name_and_id(
Expand Down

0 comments on commit ebd7b84

Please sign in to comment.