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

49 call flow issues 2 #126

Merged
merged 7 commits into from
Oct 8, 2024
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
19 changes: 19 additions & 0 deletions odins_spear/methods/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@ def user_call_center(self, user_id: str):
return response


def group_call_center_agents(self, service_user_id: str):
"""Returns list of agents assigned to the target call center.

Args:
service_user_id (str): Service user ID of target call center.

Returns:
Dict: List of agents assigned to call center
"""

endpoint = "/groups/call-centers/agents"

params = {
"serviceUserId": service_user_id
}

return self.requester.get(endpoint, params=params)


def group_call_center_bounced_calls(self, service_user_id: str):
"""Retrieves the number of rings before a call is bounced from the specified call center.

Expand Down
6 changes: 5 additions & 1 deletion odins_spear/reports/call_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def main(api, service_provider_id: str, group_id: str, number: str, number_type:

call_centers = api.get.group_call_centers(service_provider_id, group_id)
for cc in tqdm(call_centers, desc=f"Fetching all Call Centers."):
call_center = bre.CallCenter.from_dict(group= group, data= api.get.group_call_center(cc['serviceUserId']))

call_center = api.get.group_call_center(cc['serviceUserId'])
call_center['agents'] = api.get.group_call_center_agents(cc['serviceUserId'])['agents']

call_center = bre.CallCenter.from_dict(group= group, data= call_center)

try:
overflow_settings = api.get.group_call_center_overflow(call_center.service_user_id)
Expand Down
87 changes: 55 additions & 32 deletions odins_spear/reports/report_utils/graphviz_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,40 @@ class GraphvizModule:
'fontcolor': 'white'
},
'auto_attendant': {
'shape': 'circle',
'shape': 'record',
'style': 'filled',
'margin': '0.2',
'color': '#5E1008',
'fillcolor': '#FF0000',
'color': '#1C3A3A',
'fillcolor': '#356969',
'fontname': 'Arial',
'fontcolor': 'white'
},
'call_centre': {
'shape': 'Mrecord',
'shape': 'record',
'style': 'filled',
'margin': '0.2',
'color': '#68272E',
'fillcolor': '#FFC0CB',
'color': '#9773F1',
'fillcolor': '#B4A0E5',
'fontname': 'Arial',
'fontcolor': 'white'
},
'hunt_group': {
'shape': 'Mrecord',
'shape': 'record',
'style': 'filled',
'margin': '0.2',
'color': '#3D4066',
'fillcolor': '#9C1FE9',
'color': '#E892E2',
'fillcolor': '#E9BCE6',
'fontname': 'Arial',
'fontcolor': 'white'
'fontcolor': 'black'
},
'user': {
'shape': 'Mrecord',
'shape': 'record',
'style': 'filled',
'margin': '0.2',
'color': '#B87700',
'fillcolor': '#FBA200',
'color': '#CAE188',
'fillcolor': '#E3FE97',
'fontname': 'Arial',
'fontcolor': 'white'
'fontcolor': 'black'
},

}
Expand All @@ -85,14 +85,29 @@ def generate_call_flow_graph(self, nodes: list, number: str):
# build nodes
self.dot.node("Start", "Start", GraphvizModule.NODE_STYLING["start"])
for n in nodes:

try:
node_config = f"<extension> Extension: {n.extension} "
except AttributeError:
node_config = ""

if isinstance(n, bre.User):
self.dot.node(n.id, n.extension, GraphvizModule.NODE_STYLING["user"])
elif isinstance(n, bre.CallCenter):
self.dot.node(n.service_user_id, n.extension, GraphvizModule.NODE_STYLING["call_centre"])
elif isinstance(n, bre.HuntGroup):
self.dot.node(n.service_user_id, n.extension, GraphvizModule.NODE_STYLING["hunt_group"])
self.dot.node(n.id, node_config, GraphvizModule.NODE_STYLING["user"])

elif isinstance(n, bre.CallCenter) or isinstance(n, bre.HuntGroup):
node_config += f"| <name> Name: {n.name} | <policy> Policy: {n.policy}"
for i, a in enumerate(n.agents):
node_config += f"| <{a.id}> Agent {i+1}: {a.extension}"
self.dot.node(n.service_user_id, node_config,
GraphvizModule.NODE_STYLING["call_centre"] if isinstance(n, bre.CallCenter)
else GraphvizModule.NODE_STYLING["hunt_group"])

elif isinstance(n, bre.AutoAttendant):
self.dot.node(n.service_user_id, n.extension, GraphvizModule.NODE_STYLING["auto_attendant"])
node_config += f"| <name> Name: {n.name}"
for k in n.business_hours_menu.keys:
node_config += f"| <key{k.number}> Option: {k.number}"
k.id = f"{n.service_user_id}:<key{k.number}>"
self.dot.node(n.service_user_id, node_config, GraphvizModule.NODE_STYLING["auto_attendant"])

# build edges
for n in nodes:
Expand Down Expand Up @@ -133,20 +148,28 @@ def generate_call_flow_graph(self, nodes: list, number: str):
elif isinstance(n, bre.AutoAttendant):
for key in n.business_hours_menu.keys:
if "Transfer" in key.action:
self._format_edge(n, key.phone_number, key.number)
self._format_edge(key, key.phone_number, key.number)


def _format_edge(self, node_a: str, node_b: str, label: str):
try:
self.dot.edge(node_a.id, node_b.id, label, GraphvizModule.EDGE_STYLYING)
except AttributeError:
try:
self.dot.edge(node_a.id, node_b.service_user_id, label, GraphvizModule.EDGE_STYLYING)
except AttributeError:
try:
self.dot.edge(node_a.service_user_id, node_b.service_user_id, label, GraphvizModule.EDGE_STYLYING)
except AttributeError:
self.dot.edge(node_a.service_user_id, node_b.id, label, GraphvizModule.EDGE_STYLYING)
def _format_edge(self, node_a: str, node_b: str, label: str):
if node_b is None:
return None

node_a_id = node_a.id if hasattr(node_a, 'id') else node_a.service_user_id
node_b_id = node_b.id if hasattr(node_b, 'id') else node_b.service_user_id

self.dot.edge(node_a_id, node_b_id, label, GraphvizModule.EDGE_STYLYING)

# try:
# self.dot.edge(node_a.id, node_b.id, label, GraphvizModule.EDGE_STYLYING)
# except AttributeError:
# try:
# self.dot.edge(node_a.id, node_b.service_user_id, label, GraphvizModule.EDGE_STYLYING)
# except AttributeError:
# try:
# self.dot.edge(node_a.service_user_id, node_b.service_user_id, label, GraphvizModule.EDGE_STYLYING)
# except AttributeError:
# self.dot.edge(node_a.service_user_id, node_b.id, label, GraphvizModule.EDGE_STYLYING)


def _save_graph(self, filename: str):
Expand Down