From 918f8e6f8ef416ad13c96c8956993b2f8b6004e7 Mon Sep 17 00:00:00 2001 From: Daniel Jimenez Date: Mon, 6 Jan 2025 21:21:27 +1300 Subject: [PATCH] fix: AgentTable report showing test value for zero conversations (#10641) # Pull Request Template ## Description Changed to make use of nullish coalescing operator to only short circuit in cases when the `metric` variable is not zero. This change also begs the question as to whether the `stringToFloat` test function should exist - to me it seems interesting to have test code embedded into production code for the frontend? Fixes #10640 ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality not to work as expected) - [ ] This change requires a documentation update ## How Has This Been Tested? Tested by opening the report overview page and reviewing that this shows `---` for agents with no conversations assigned to them. ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [x] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: Shivam Mishra --- .../components/overview/AgentTable.vue | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/settings/reports/components/overview/AgentTable.vue b/app/javascript/dashboard/routes/dashboard/settings/reports/components/overview/AgentTable.vue index 810db7029..fb470d8fc 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/reports/components/overview/AgentTable.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/reports/components/overview/AgentTable.vue @@ -39,28 +39,6 @@ function getAgentInformation(id) { return agents?.find(agent => agent.id === Number(id)); } -// use for debuggin -function stringToFloat(inputString) { - if (!inputString) { - return 0.0; - } - - // Sum the Unicode values of all characters - const unicodeSum = Array.from(inputString).reduce( - (sum, char) => sum + char.charCodeAt(0), - 0 - ); - - // Use a large prime number to create more variance - const prime = 2147483647; // Mersenne prime (2^31 - 1) - - // Generate a hash-like value - const hashValue = unicodeSum * prime; - - // Normalize to [0, 1] range - return (hashValue % 1000000) / 1000000.0; -} - const totalCount = computed(() => agents.length); const tableData = computed(() => { @@ -72,12 +50,8 @@ const tableData = computed(() => { agent: agentInformation.name || agentInformation.available_name, email: agentInformation.email, thumbnail: agentInformation.thumbnail, - open: - agent.metric.open || - Math.floor(stringToFloat(agentInformation.email) * 50), - unattended: - agent.metric.unattended || - Math.floor(stringToFloat(agentInformation.email) * 30), + open: agent.metric.open ?? 0, + unattended: agent.metric.unattended ?? 0, status: agentInformation.availability_status, }; });