-
Notifications
You must be signed in to change notification settings - Fork 15
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
fix: Update metrics calculations and related UI components #1172
Merged
stalgiag
merged 11 commits into
development
from
update-metricsCalculation-and-progressbar
Jul 25, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
56cf1ad
Address missing db persisted calculation for exclusions (this wasn't …
howard-e a83e8c2
Revise aria-label with progress bar to avoid double speech
howard-e fa4aaab
Update getMetrics to stop rounding up and use utilities
howard-e 6b0f44f
Remove Math.round usage on candidate test plans page
howard-e 36e306e
Update shared/calculations usage
howard-e 12e11e8
Include migration and better handling of finalizedTestResultsResolver.js
howard-e 057f17b
Add tests for getMetrics
howard-e a26727a
Add tests for getMetrics
howard-e 0d8dd48
Add tests for getMetrics
howard-e 91208f7
Reduce noisy aria-labels
howard-e c6025be
Additional clarifying comments
howard-e File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use strict'; | ||
|
||
const { getMetrics } = require('shared'); | ||
const populateData = require('../services/PopulatedData/populateData'); | ||
const runnableTestsResolver = require('../resolvers/TestPlanReport/runnableTestsResolver'); | ||
const finalizedTestResultsResolver = require('../resolvers/TestPlanReport/finalizedTestResultsResolver'); | ||
const { | ||
updateTestPlanReportById | ||
} = require('../models/services/TestPlanReportService'); | ||
const getGraphQLContext = require('../graphql-context'); | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
return queryInterface.sequelize.transaction(async transaction => { | ||
const context = getGraphQLContext({ req: { transaction } }); | ||
|
||
const testPlanReports = await queryInterface.sequelize.query( | ||
`select distinct on ("TestPlanReport".id) "TestPlanReport".id, metrics | ||
from "TestPlanReport" | ||
join public."TestPlanRun" testPlanRun on "TestPlanReport".id = testPlanRun."testPlanReportId" | ||
where jsonb_array_length(testPlanRun."testResults") > 0;`, | ||
{ | ||
type: Sequelize.QueryTypes.SELECT, | ||
transaction | ||
} | ||
); | ||
|
||
for (const testPlanReport of testPlanReports) { | ||
const { testPlanReport: testPlanReportPopulated } = await populateData( | ||
{ testPlanReportId: testPlanReport.id }, | ||
{ context } | ||
); | ||
const runnableTests = runnableTestsResolver( | ||
testPlanReportPopulated, | ||
null, | ||
context | ||
); | ||
const finalizedTestResults = await finalizedTestResultsResolver( | ||
testPlanReportPopulated, | ||
null, | ||
context | ||
); | ||
const metrics = getMetrics({ | ||
testPlanReport: { | ||
...testPlanReportPopulated, | ||
finalizedTestResults, | ||
runnableTests | ||
} | ||
}); | ||
await updateTestPlanReportById({ | ||
id: testPlanReportPopulated.id, | ||
values: { | ||
metrics: { | ||
...testPlanReportPopulated.metrics, | ||
...metrics | ||
} | ||
}, | ||
transaction | ||
}); | ||
} | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @param {number} value | ||
* @param {number} total | ||
* @param {boolean} ignoreError - to account for cases where having a NaN is "expected" | ||
* @returns {number} | ||
*/ | ||
const calculatePercentage = (value, total, { ignoreError = true } = {}) => { | ||
if (!ignoreError && total === 0) { | ||
throw new Error("Unable to divide. 'total' cannot be 0."); | ||
} | ||
return (value / total) * 100; | ||
}; | ||
|
||
const trimDecimals = (number, decimals = 0) => { | ||
if (decimals === undefined || decimals <= 0) { | ||
return Math.floor(number); | ||
} else { | ||
let factor = Math.pow(10, decimals); | ||
return Math.floor(number * factor) / factor; | ||
} | ||
}; | ||
|
||
module.exports = { | ||
calculatePercentage, | ||
trimDecimals | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const calculations = require('./calculations'); | ||
const convertAssertionPriority = require('./convertAssertionPriority'); | ||
const getMetrics = require('./getMetrics'); | ||
module.exports = { convertAssertionPriority, getMetrics }; | ||
|
||
module.exports = { calculations, convertAssertionPriority, getMetrics }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers: Found odd behaviors when doing the following: