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 <scm.mymail@gmail.com>
This commit is contained in:
Daniel Jimenez
2025-01-06 21:21:27 +13:00
committed by GitHub
parent 5e4e955e64
commit 918f8e6f8e

View File

@@ -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,
};
});