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

NAS-114805 / 22.12 / NAS-114805: Refactoring scheduler component #6440

Merged
merged 14 commits into from
Mar 2, 2022

Conversation

undsoft
Copy link
Collaborator

@undsoft undsoft commented Feb 24, 2022

Testing: go to Settings -> General -> GUI, observe new "test" input.

Notes:

  • The form is not designed to save.
  • Pay extra attention to Custom option.
  • Pay extra attention to timezones.
  • Modal looks different - that's okay, review it from usability perspective.

@undsoft undsoft requested a review from a team as a code owner February 24, 2022 15:46
@undsoft undsoft requested review from RehanY147 and removed request for a team February 24, 2022 15:46
@bugclerk
Copy link
Contributor

@bugclerk bugclerk changed the title NAS-114805: Refactoring scheduler component NAS-114805 / 22.12 / NAS-114805: Refactoring scheduler component Feb 24, 2022
Copy link
Collaborator

@dszidi dszidi left a comment

Choose a reason for hiding this comment

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

On a fresh page reload with caches cleared I get this. The current date is not highlighted and dates in the past that match the cron rule settings are also selected. Editing fields in the form seem to fix this though.

image

Copy link
Collaborator

@dszidi dszidi left a comment

Choose a reason for hiding this comment

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

This rule causes incorrect preview showing the date in the past. It only does this when you select the current month.

image

We probably don't want to show anything in the past in the preview or the controls (month drop down selector), since the main goal is to help users understand what the cron tab settings would schedule in the future.

Copy link
Contributor

@RehanY147 RehanY147 left a comment

Choose a reason for hiding this comment

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

I noticed the same issues as described by Damian above.

}

nextRuns.push(exampleDate);
i = i + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not have this in the for loop declaration? for (let i = 0; i < limit; i++)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because there is a continue condition that doesn't actually need it.

let previousDate = toDate(startDate, { timeZone: 'UTC' });
const startingMonth = getMonth(previousDate);

while (getMonth(previousDate) === startingMonth) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This might as well be while(true). Condition for the loop should be the actual loop condition (where break is called maybe?). Could be replaced by do{...} while(condition). Not sure.


private isWithinTimeConstrains(date: Date): boolean {
return true;
// TODO: Will be implemented later.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because I got tired :) It's an edge case feature that I will address in coming PRs soon.

weekdays: weekdayValues,
});
} catch (error: unknown) {
console.error(error);
Copy link
Contributor

Choose a reason for hiding this comment

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

console.error seems inconsequential for running into an error while patching values. Typical users obvi won't notice it. Have noticed it else where in this PR as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here and in other places, I have console.error to log error in Sentry mostly.
This particular try catch wraps around cronParser.parseExpression

@undsoft
Copy link
Collaborator Author

undsoft commented Feb 28, 2022

Comments got addressed.

We probably don't want to show anything in the past in the preview or the controls (month drop down selector), since the main goal is to help users understand what the cron tab settings would schedule in the future.

While I generally agree that there is no use for being able to go back in time, I decided to keep this functionality for two reasons. It doesn't harm, provides some clues and it would require a bit of ugly code to fix it.

@undsoft undsoft requested review from dszidi and RehanY147 February 28, 2022 17:02
Copy link
Contributor

@RehanY147 RehanY147 left a comment

Choose a reason for hiding this comment

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

When selecting daily, the first of each month is shown not selected when a timestamp for it is visible in the list. Same for weekly. If the first day of the period falls on the 1st of the month, it is not shown as selected.
image

@undsoft undsoft requested a review from RehanY147 March 1, 2022 11:02
@undsoft
Copy link
Collaborator Author

undsoft commented Mar 1, 2022

Alright, let's try this again.

Copy link
Contributor

@RehanY147 RehanY147 left a comment

Choose a reason for hiding this comment

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

There should be some visual separation between what is the value and what is the description.
image
Also, should add a white space between )At
image

@undsoft
Copy link
Collaborator Author

undsoft commented Mar 1, 2022

Fixed.

Снимок экрана 2022-03-01 в 16 08 21

@undsoft undsoft requested a review from RehanY147 March 1, 2022 13:08
@dszidi
Copy link
Collaborator

dszidi commented Mar 1, 2022

Since we're allowing events in the past, the calendar should also respect this. When I select a specific hour that has already passed in the current day, the calendar view does not highlight the current day.

image

@undsoft
Copy link
Collaborator Author

undsoft commented Mar 1, 2022

That's kinda not what I meant. You can go to past months - yes, mostly to keep code clean, but also to keep calendar UI consistent, but we won't be showing past events.

@dszidi
Copy link
Collaborator

dszidi commented Mar 1, 2022

That's kinda not what I meant. You can go to past months - yes, mostly to keep code clean, but also to keep calendar UI consistent, but we won't be showing past events.

So users should be able to navigate the calendar view into the past but no dates should be highlighted.

Copy link
Collaborator

@dszidi dszidi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@RehanY147 RehanY147 left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@undsoft undsoft merged commit eecb010 into master Mar 2, 2022
@undsoft undsoft deleted the NAS-114805 branch March 2, 2022 11:55
@Hexagon
Copy link

Hexagon commented Mar 2, 2022

@undsoft If you use croner to build cron strings, but actually run tasks using system cron. I would recommend using 4.2 and enabling the legacyMode option

See Hexagon/croner#53 for details

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.

5 participants