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

Common scheduler #1641

Merged
merged 5 commits into from
Feb 10, 2023
Merged

Conversation

atrovato
Copy link
Contributor

@atrovato atrovato commented Nov 4, 2022

Pull Request check-list

To ensure your Pull Request can be accepted as fast as possible, make sure to review and check all of these items:

  • If your changes affects code, did your write the tests?
  • Are tests passing? (npm test on both front/server)
  • Is the linter passing? (npm run eslint on both front/server)
  • Did you run prettier? (npm run prettier on both front/server)
  • [ ] If you are adding a new features/services, did you run integration comparator? (npm run compare-translations on front)
  • Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community for testing before merging.
  • [ ] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
  • [ ] If you are adding a new features/services which needs explanation, did you modify the user documentation? See the GitHub repo and the website.
  • [ ] Did you add fake requests data for the demo mode (front/src/config/demo.js) so that the demo website is working without a backend? (if needed) See https://demo.gladysassistant.com.

NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.

Description of change

Gladys core and common scheduler

  • unify usage of the node-schedule library
  • add scheduleJob in Gladys scheduler (accessible from services)
  • split tests and improve coverage

Changes

Now scheduler-jobs are crons instead of interval.

@codecov
Copy link

codecov bot commented Nov 4, 2022

Codecov Report

Base: 97.29% // Head: 97.52% // Increases project coverage by +0.23% 🎉

Coverage data is based on head (b974303) compared to base (9fd61ec).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1641      +/-   ##
==========================================
+ Coverage   97.29%   97.52%   +0.23%     
==========================================
  Files         646      646              
  Lines        9753     9734      -19     
==========================================
+ Hits         9489     9493       +4     
+ Misses        264      241      -23     
Impacted Files Coverage Δ
server/config/scheduler-jobs.js 100.00% <ø> (ø)
server/lib/gateway/gateway.handleNewMessage.js 91.42% <100.00%> (ø)
server/lib/gateway/gateway.init.js 84.61% <100.00%> (+1.28%) ⬆️
server/lib/gateway/gateway.login.js 100.00% <100.00%> (+26.31%) ⬆️
server/lib/gateway/index.js 100.00% <100.00%> (ø)
server/lib/index.js 94.87% <100.00%> (ø)
server/lib/scene/index.js 100.00% <100.00%> (ø)
server/lib/scene/scene.addScene.js 96.29% <100.00%> (+3.70%) ⬆️
server/lib/scene/scene.dailyUpdate.js 100.00% <100.00%> (ø)
server/lib/scene/scene.init.js 100.00% <100.00%> (ø)
... and 12 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@Pierre-Gilles Pierre-Gilles left a comment

Choose a reason for hiding this comment

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

Thanks for this PR, great work! 🙂

I added a few comments. I'm not sure I'm confident with this PR modifying Gladys Plus code, it's changing the scope of this review to a whole different level 😅

Gladys Plus has paying customers, so I can't change things without serious real-life testing. I'm really trying to have Gladys Plus to be as stable as possible.

I hope you understand !

server/lib/gateway/gateway.handleAlexaMessage.js Outdated Show resolved Hide resolved
server/lib/gateway/gateway.login.js Outdated Show resolved Hide resolved
server/lib/scheduler/scheduler.cancelJob.js Show resolved Hide resolved
server/test/lib/gateway/gateway.test.js Show resolved Hide resolved
server/lib/gateway/gateway.init.js Outdated Show resolved Hide resolved
@atrovato atrovato force-pushed the common-scheduler branch 3 times, most recently from b89962e to 1521eb9 Compare December 3, 2022 08:54
@atrovato
Copy link
Contributor Author

atrovato commented Dec 3, 2022

I totally understand, I rollback some un-necessary changes, but some are required to use the common scheduler.
I will generate a "easy-to-read" diff file to check that tests are not that impacted.

@Pierre-Gilles
Copy link
Contributor

@atrovato Thank you 🙏 Let me know when it's ready for review again

@atrovato
Copy link
Contributor Author

Hi @Pierre-Gilles, I'm ready for a new review.
There is some comments that I didn't mark as resolved to let you check easily if it's fine for you.

Please find a comparison between "ol" and "new" version of tests.
At left side, the old one.
At right side, the new one (before and after where cleaned in comparison to make it clearer).

out2.zip

Copy link
Contributor

@Pierre-Gilles Pierre-Gilles left a comment

Choose a reason for hiding this comment

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

Thanks for your fixes! It's super clear to me, and I agree with the improvements in the Gateway tests, thanks for them 🙏

I have a few feedbacks but nothing really serious :)

server/lib/gateway/gateway.init.js Outdated Show resolved Hide resolved
server/lib/scene/scene.addScene.js Outdated Show resolved Hide resolved
server/lib/scene/scene.init.js Outdated Show resolved Hide resolved
server/lib/scheduler/scheduler.scheduleJob.js Outdated Show resolved Hide resolved
@atrovato atrovato force-pushed the common-scheduler branch 4 times, most recently from e2cbbdb to da9626a Compare December 24, 2022 10:31
@Pierre-Gilles
Copy link
Contributor

@atrovato is this ready for a new review ? Let me know :)

@atrovato
Copy link
Contributor Author

atrovato commented Jan 3, 2023

I just rebased it, yes ready for new review :) @Pierre-Gilles

@Pierre-Gilles
Copy link
Contributor

Pierre-Gilles commented Jan 23, 2023

@atrovato I reviewed the code and it looks good to me. But I need to test it in real-life because it's an important change!

Do you have a Docker image to try it ?

@atrovato
Copy link
Contributor Author

atrovato/gladys:common-scheduler is building for now ;)

@Pierre-Gilles
Copy link
Contributor

Pierre-Gilles commented Feb 9, 2023

@atrovato I started an instance with your image. Let's see in the coming day if all jobs are executing as expected

Which behavior have you tested in real life (just to know) ?

Needs to be tested :

  • Hourly aggregate
  • Sunrise/Sunset scenes
  • Creating a scene
  • Daily backups
  • Gateway login
  • Amazon Alexa integration
  • Google Home integration

Copy link
Contributor

@Pierre-Gilles Pierre-Gilles left a comment

Choose a reason for hiding this comment

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

Tested on my side in real life, thanks for this PR, everything works fine! 🙏

@Pierre-Gilles Pierre-Gilles merged commit 10e252f into GladysAssistant:master Feb 10, 2023
@relativeci
Copy link

relativeci bot commented Feb 10, 2023

Job #1081: Bundle Size — 7.19MiB (0%).

10e252f(current) vs 9fd61ec master#1068(baseline)

Metrics (no changes)
                 Current
Job #1081
     Baseline
Job #1068
Initial JS 4.21MiB 4.21MiB
Initial CSS 300KiB 300KiB
Cache Invalidation 0% 0%
Chunks 51 51
Assets 149 149
Modules 1338 1338
Duplicate Modules 1 1
Duplicate Code 0.01% 0.01%
Packages 116 116
Duplicate Packages 4 4
Total size by type (no changes)
                 Current
Job #1081
     Baseline
Job #1068
CSS 313.13KiB 313.13KiB
Fonts 93.55KiB 93.55KiB
HTML 13.58KiB 13.58KiB
IMG 1.66MiB 1.66MiB
JS 5.11MiB 5.11MiB
Media 0B 0B
Other 15.74KiB 15.74KiB

View job #1081 reportView master branch activity

euguuu pushed a commit to euguuu/Gladys that referenced this pull request Mar 5, 2023
@atrovato atrovato deleted the common-scheduler branch March 18, 2023 18:32
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