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

fix the script to treat the value 0 not as falsy values. #441

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

lindaxiang
Copy link
Contributor

@lindaxiang lindaxiang commented Oct 21, 2024

The issue (#440) arises because the script treats the value 0 as falsy in the condition (!$field || $field === null || checkforEmpty($field)), so it incorrectly triggers the validation error.

Steps To Test

Context:

  • Environment: QA
  • Program: MONSTAR-JP
  • Submitter Donor ID: MS0010022

Steps to test the behaviour:

  1. Go to 'https://platform-ui.argo-qa.cumulus.genomeinformatics.org/' and login
  2. Click on 'MONSTAR-JP' and tab 'Submit Clinical Data'
  3. Click on 'UPLOAD FILES'
  4. Submit the following test file
  1. Check the column 'treatment_start_interval' now accept value of 0
  2. Click on 'VALIDATE SUBMISSION' and no errors are showing up.
  3. Go ahead to "SIGN OFF SUBMISSION"

@justincorrigible justincorrigible force-pushed the 440_treatment_start_interval branch 2 times, most recently from e54e036 to 3e8ee4e Compare October 21, 2024 22:02
Copy link
Member

@justincorrigible justincorrigible left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the styling/linting blurred the changes differential, some comments to clarify what I added

Comment on lines +31 to +37
"prettier": {
"printWidth": 120,
"trailingComma": "all",
"semi": true,
"singleQuote": true,
"tabWidth": 4,
"useTabs": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to help with consistent styling

Comment on lines 48 to 58
const checkforInvalid = entry => {
const entryAsNumber = parseFloat($field); // to validate it as a numnber

const recordHasTreatments = !arrayItemsInSecondArray(
treatmentExceptionTypes,
treatmentTypes,
);
return (
[null, undefined, ''].includes($field) || // first dispose of the regular falsy values
(!isNaN(entryAsNumber) && entryAsNumber < 0) || // checks for valid numbers
/^\s+$/g.test(decodeURI(entry).replace(/^"(.*)"$/, '$1'))
); // whitespace-filled strings
};
Copy link
Member

@justincorrigible justincorrigible Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checkForInvalid function now checks beyond whitespace strings whether there's falsy values given, while allowing 0+ to pass.

Copy link
Contributor Author

@lindaxiang lindaxiang Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry @justincorrigible I forgot to mention that the intervals have been adjusted to accept negative numbers: #436
By definition, all intervals are allowed to accept integers including negative, positive and 0. For example:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh! good to know! the code should reflect that 👍
I'll make the changes and document as a comment for future reference
(using explanation in #432)

Comment on lines 85 to 101
[
'treatment_start_interval is submitted to be a fraction when treatment was given',
true,
loadObjects(treatment, {
treatment_start_interval: 0.5,
treatment_type: ['Surgery'],
}),
],
[
'treatment_start_interval is submitted to be negative when treatment was given',
false,
loadObjects(treatment, {
treatment_start_interval: -0.2,
treatment_type: ['Ablation'],
}),
],
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of additional tests to ensure even fractions pass, but not negative numbers.

@justincorrigible justincorrigible force-pushed the 440_treatment_start_interval branch from 3e8ee4e to 43b12c7 Compare October 22, 2024 15:38
@justincorrigible justincorrigible merged commit 60ba8a2 into develop Oct 22, 2024
@justincorrigible justincorrigible deleted the 440_treatment_start_interval branch October 22, 2024 15:44
lindaxiang added a commit that referenced this pull request Oct 22, 2024
fix the treatment interval validation script to accept 0 (#441)
justincorrigible pushed a commit that referenced this pull request Oct 22, 2024
fix the treatment interval validation script to accept 0 (#441)
@justincorrigible
Copy link
Member

postmortem comment: this PR removed a parenthesis that wraps the script, which we've realised was mandatory, and had to re-add afterwards. Tabs indentation is okay though, which is great for accessibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants