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

feature: return dashboard agent last name #424

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions chats/apps/api/v1/dashboard/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@dataclass
class Agent:
first_name: str = None
last_name: str = None
email: str = None
agent_status: str = None
closed_rooms: int = None
Expand Down
8 changes: 7 additions & 1 deletion chats/apps/api/v1/dashboard/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,19 @@ def get_agents_data(self, filters: Filters, project) -> List[Agent]:
opened_rooms=Count("rooms", filter=Q(**opened_rooms, **rooms_filter)),
)
.values(
"first_name", "email", "agent_status", "closed_rooms", "opened_rooms"
"first_name",
"last_name",
"email",
"agent_status",
"closed_rooms",
"opened_rooms",
)
)

user_agents = [
Agent(
first_name=user_agent["first_name"],
last_name=user_agent["last_name"],
email=user_agent["email"],
agent_status=user_agent["agent_status"],
closed_rooms=user_agent["closed_rooms"],
Expand Down
1 change: 1 addition & 0 deletions chats/apps/api/v1/dashboard/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def dashboard_general_data(context: dict, project):

class DashboardAgentsSerializer(serializers.Serializer):
first_name = serializers.CharField(allow_null=True, required=False)
last_name = serializers.CharField(allow_null=True, required=False)
email = serializers.EmailField(allow_null=True, required=False)
agent_status = serializers.CharField(allow_null=True, required=False)
closed_rooms = serializers.IntegerField(allow_null=True, required=False)
Expand Down
2 changes: 2 additions & 0 deletions chats/apps/dashboard/tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_returned_fields_from_get_agents_data(self):
)
for fields in agents_fields:
self.assertTrue(hasattr(fields, "first_name"))
self.assertTrue(hasattr(fields, "last_name"))
self.assertTrue(hasattr(fields, "email"))
self.assertTrue(hasattr(fields, "agent_status"))
self.assertTrue(hasattr(fields, "closed_rooms"))
Expand All @@ -39,6 +40,7 @@ def test_field_value_from_dashboard_agent_serializer(self):
)

self.assertEqual(agents_fields[2].first_name, "")
self.assertEqual(agents_fields[2].last_name, "")
self.assertEqual(agents_fields[2].email, "[email protected]")
self.assertEqual(agents_fields[2].agent_status, "OFFLINE")
self.assertEqual(agents_fields[2].closed_rooms, 0)
Expand Down
1 change: 1 addition & 0 deletions chats/apps/dashboard/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_active_chats_function_without_filter(self):
def test_returned_fields_from_dashboard_agent_serializer(self):
serializer_data: Dict[str, Any] = {
"first_name": "John",
"last_name": "Smith",
"email": "invalid_email",
"agent_status": "ACTIVE",
"closed_rooms": 3,
Expand Down
Loading