Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

138 Reg Report - Added Lineport #151

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
15 changes: 11 additions & 4 deletions odins_spear/reports/user_registration_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ def export_to_xlsx(data: dict, group_id: str):
registration = user_data.get("registration", {})

if not registration:
rows.append([user_id, None, False])
rows.append([user_id, None, None, False])
else:
for device_name, registration_info in registration.items():
for device_name, registration_info in enumerate(registration):
rows.append(
[user_id, device_name, registration_info.get("registered", False)]
[
user_id,
registration_info.get("deviceName", device_name),
registration_info.get("linePort"),
registration_info.get("registered", False),
]
)

dataframe = pd.DataFrame(rows, columns=["User ID", "Device Name", "Registered"])
dataframe = pd.DataFrame(
rows, columns=["User ID", "Device Name", "Line Port", "Registered"]
)
dataframe.to_excel(
f"./os_reports/Registration_report_for_{group_id}.xlsx",
index=False,
Expand Down
15 changes: 10 additions & 5 deletions odins_spear/scripts/user_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ def main(api, service_provider_id: str, group_id: str):
for user in users:

user_id = user["profile"]["userId"]
registrations_out[user_id] = {"registration": {}} # Initialise the dictionary
registrations_out[user_id] = {"registration": []} # Initialise the dictionary

for registration in user["data"]["registrations"]:

device_name = registration["deviceName"]

registrations_out[user_id]["registration"][device_name] = {
"registered": True
} # All devices listed under the "registrations" attribute must be registered, so always True.
line_port = registration["linePort"]

return registrations_out
registrations_out[user_id]["registration"].append({
"deviceName": device_name,
"linePort": line_port,
"registered": True,
})


return registrations_out
Binary file modified requirements.txt
Binary file not shown.
Loading