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

[O2B-643] Run duration accept format HH:MM:SS #1464

Draft
wants to merge 56 commits into
base: main
Choose a base branch
from

Conversation

xsalonx
Copy link
Collaborator

@xsalonx xsalonx commented Mar 15, 2024

I have a JIRA ticket

  • branch and/or PR name(s) include(s) JIRA ID
  • issue has "Fix version" assigned
  • issue "Status" is set to "In review"
  • PR labels are selected

Notable changes for users:

  • Changed run duration filter to accept number of hours, minutes and seconds

Notable changes for developers:

  • NA

Changes made to the database:

  • NA

@xsalonx xsalonx self-assigned this Mar 15, 2024
@xsalonx xsalonx marked this pull request as ready for review March 15, 2024 09:30
@xsalonx xsalonx marked this pull request as draft March 15, 2024 09:31
@xsalonx xsalonx marked this pull request as ready for review March 15, 2024 10:55
Copy link

codecov bot commented Mar 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 123 lines in your changes missing coverage. Please review.

Project coverage is 43.51%. Comparing base (c6ba263) to head (eb7ae9f).

Files with missing lines Patch % Lines
...ib/public/views/Runs/Overview/RunsOverviewModel.js 0.00% 58 Missing ⚠️
...omponents/common/form/inputs/DurationInputModel.js 0.00% 23 Missing ⚠️
...ents/Filters/common/filters/DurationFilterModel.js 0.00% 22 Missing ⚠️
...ic/components/Filters/RunsFilter/durationFilter.js 0.00% 16 Missing ⚠️
...common/filters/ComparisonOperatorSelectionModel.js 0.00% 3 Missing ⚠️
...blic/views/Runs/ActiveColumns/runsActiveColumns.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1464      +/-   ##
==========================================
- Coverage   43.82%   43.51%   -0.31%     
==========================================
  Files         889      892       +3     
  Lines       15761    15872     +111     
  Branches     2939     2973      +34     
==========================================
  Hits         6907     6907              
- Misses       8854     8965     +111     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@martinboulais martinboulais left a comment

Choose a reason for hiding this comment

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

I have put several comments on things that I have already commented too much times.
Please have a look, fix what I commented, and try to fix the rest (do it carefully, especially prune from this PR everything that do not belongs to it)

lib/public/components/Filters/RunsFilter/durationFilter.js Outdated Show resolved Hide resolved
lib/public/components/Filters/RunsFilter/nDetectors.js Outdated Show resolved Hide resolved
lib/public/components/Filters/RunsFilter/nEpns.js Outdated Show resolved Hide resolved
lib/public/components/Filters/RunsFilter/nFlps.js Outdated Show resolved Hide resolved
lib/public/views/Runs/Overview/RunsOverviewModel.js Outdated Show resolved Hide resolved
lib/public/views/Runs/Overview/RunsOverviewModel.js Outdated Show resolved Hide resolved
test/public/defaults.js Outdated Show resolved Hide resolved
@xsalonx xsalonx marked this pull request as draft May 30, 2024 10:01
@xsalonx xsalonx marked this pull request as ready for review May 30, 2024 12:13
@xsalonx xsalonx marked this pull request as draft May 30, 2024 12:44
@xsalonx xsalonx marked this pull request as ready for review June 3, 2024 12:34
const { hours, minutes, seconds } = durationInputModel.raw;

/**
* Return oninput handler for given time unit
Copy link
Collaborator

Choose a reason for hiding this comment

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

Never mention what the function should be used for, only explain what it does.

* @param {'hours'|'minutes'|'seconds'} unitName time unit
* @return {function(InputEvent, void)} oninput handler for input for given time unit
*/
const updateInputModelHandlerByTimeUnit = (unitName) => (e) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function seems to add more complexity than it brings value I think

const { value } = e.target;
const parsedValue = Number(value);
if (value.length > 0 || 0 <= parsedValue && (unitName === 'hours' || parsedValue < 60)) {
durationInputModel.update({ [unitName]: value.length > 0 ? parsedValue : null });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doing so, if you delete a value, update will not be triggered, so it will be put back to previous value.
Plus, this kind of processing should be in the model.
What you do in oninput is simply call durationFilterModel update, pass it RAW value (i.e. the string input), you store this raw value and try to extract the actual value.
If user put 80 minutes you still need to keep this as raw value but mark the input as invalid, and not update the actual value.
Please have a look at other inputs, such as DateTimeInputComponent

Comment on lines +33 to +39
this._operatorSelectionModel.observe(() => {
if (this._durationInputModel.value === null) {
this._visualChange$.notify();
} else {
this.notify();
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not how it should work I suppose. If operatorSelectionModel has visualChange you need to bubleUp this to the current visualChange, but not mix the global notify and the visual change

Comment on lines 53 to 65
try {
this._raw = { ...this._raw, ...raw };
this._value =
(this._raw.hours || 0) * 60 * 60 * 1000 +
(this._raw.minutes || 0) * 60 * 1000 +
(this._raw.seconds || 0) * 1000;

if (this._value === 0) {
this.reset();
const { hours, minutes, seconds } = this._raw;
if ((hours ?? minutes ?? seconds ?? null) === null) {
this._value = null;
} else {
this._value = (hours || 0) * 60 * 60 * 1000
+ (minutes || 0) * 60 * 1000
+ (seconds || 0) * 1000;
}
} catch (_) {
} catch {
this._value = null;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the try catch?

'filter[runDuration][operator]': this._runDurationOperatorSelectionModel.selected,
'filter[runDuration][limit]': this._runDurationFilterModel.value,
...!this._runDurationFilterModel.isEmpty() && {
'filter[runDuration][operator]': this._runDurationFilterModel.operatorSelectionModel.selected[0],
Copy link
Collaborator

Choose a reason for hiding this comment

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

you should use current instead

*
* @return {Promise<void>} resolve once row's values were checked
*/
module.exports.expectRowValues = async (page, rowId, expectedInnerTextValues) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is this used? It looks like it's not, and tbh I think it's a good thing because I don't really see where it make sense.

@@ -634,13 +658,16 @@ module.exports.checkColumnValuesWithRegex = async (page, columnId, expectedValue
valuesCheckingMode = 'every',
negation = false,
} = options;

const adjustedRegExp = new RegExp(expectedValuesRegex).toString().slice(1, -1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please explain why you do that?
Why not

if (typeof expectedValuesRegex === 'string') {
    expectedValuesRegex = new RegExp(expectedValuesRegex);
}

* Constructor
* @param {string} [defaultOperator = '='] one of ['<', '<=', '=', '>=', '>'] operators
*/
constructor(defaultOperator = '=') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you don't override this parameter anywhere, simply don't add it

oninput: updateInputModelHandlerByTimeUnit('seconds'),
}, 's');

const inputs = h('.flex-row.w-100', [
Copy link
Collaborator

Choose a reason for hiding this comment

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

is w-100 usefull? Can't we use flex-grow or equivalent instead?

@xsalonx xsalonx marked this pull request as draft August 8, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants