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

72 update to api will cause issue with group user call statistics #116

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions odins_spear/reports/group_users_call_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def main(api: object, service_provider_id: str, group_id: str,
user_services = api.get.user_services(
user_id=user["userId"]
)

except Exception:
# attempt 2
# attempt 2 in case of connection time out
try:
user_statistics = api.get.users_stats(
user["userId"],
Expand All @@ -73,19 +73,29 @@ def main(api: object, service_provider_id: str, group_id: str,
failed_users.append(user)
continue

user_statistics["servicePackServices"] = [service["serviceName"] for service in user_services["servicePackServices"] if service["assigned"]]

# Correction for API removing userId if no calls made by user
if user_statistics["userId"] is None:
user_statistics["userId"] = user["userId"]
if not user_statistics:
Jordan-Prescott marked this conversation as resolved.
Show resolved Hide resolved
user_statistics = {
"userId": user["userId"],
"total": 0,
"totalAnsweredAndMissed": 0,
"answeredTotal": 0,
"missedTotal": 0,
"busyTotal": 0,
"redirectTotal": 0,
"receivedTotal": 0,
"receivedMissed": 0,
"receivedAnswered": 0,
"placedTotal": 0,
"placedMissed": 0,
"placedAnswered": 0
}

user_statistics["servicePackServices"] = [service["serviceName"] for service in user_services["servicePackServices"] if service["assigned"]]

user_statistic_record = call_records_statistics.from_dict(user["firstName"], user["lastName"], user["extension"], user_statistics)
group_users_statistics.append(user_statistic_record)

# replace none with 0 if data returns None. Output is better if 0 allows user to make use of data better
for record in tqdm(group_users_statistics, "Formatting individual stats for each user"):
record.replace_none_with_0()

output_directory = "./os_reports"
file_name = os.path.join(output_directory, f"{group_id} User Call Statistics - {start_date} to {end_date}.csv")

Expand Down
7 changes: 0 additions & 7 deletions odins_spear/reports/report_utils/report_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ class call_records_statistics:
placedTotal: str
placedMissed: str
placedAnswered: str

def replace_none_with_0(self):
for field in fields(self):
value = getattr(self, field.name)
# Replace None with 0
if value is None or value == 'None':
setattr(self, field.name, 0)

@classmethod
def from_dict(cls, first_name, last_name, extension, data):
Expand Down