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

Z2m clean code #1639

Merged
merged 3 commits into from
Nov 25, 2022
Merged

Conversation

atrovato
Copy link
Contributor

@atrovato atrovato commented Nov 1, 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

This PR prepares the "z2m backup" feature.

The z2m code is a bit disorganized, so to add features in it, it looks difficult and risky.
So I just ran a cleaning and organization phase.

It cleans the current z2m service code to:

  • use "debug" logger instead of "log"
  • load and store variables in Gladys database in a unique method (instead of everywhere in methods)
  • clean tests when proxyquire is not required
  • implements afterEach when needed on tests
  • ...

I tested it in real life, in both upgrading and new install modes.
It looks good.

@codecov
Copy link

codecov bot commented Nov 1, 2022

Codecov Report

Base: 96.81% // Head: 96.81% // Decreases project coverage by -0.00% ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1639      +/-   ##
==========================================
- Coverage   96.81%   96.81%   -0.01%     
==========================================
  Files         660      662       +2     
  Lines        9650     9647       -3     
==========================================
- Hits         9343     9340       -3     
  Misses        307      307              
Impacted Files Coverage Δ
server/services/zigbee2mqtt/lib/constants.js 100.00% <ø> (ø)
...services/zigbee2mqtt/api/zigbee2mqtt.controller.js 100.00% <100.00%> (ø)
server/services/zigbee2mqtt/lib/connect.js 100.00% <100.00%> (ø)
server/services/zigbee2mqtt/lib/disconnect.js 100.00% <100.00%> (ø)
...erver/services/zigbee2mqtt/lib/getConfiguration.js 100.00% <100.00%> (ø)
...rver/services/zigbee2mqtt/lib/handleMqttMessage.js 100.00% <100.00%> (ø)
server/services/zigbee2mqtt/lib/index.js 100.00% <100.00%> (ø)
server/services/zigbee2mqtt/lib/init.js 100.00% <100.00%> (ø)
...r/services/zigbee2mqtt/lib/installMqttContainer.js 100.00% <100.00%> (ø)
...er/services/zigbee2mqtt/lib/installZ2mContainer.js 100.00% <100.00%> (ø)
... and 4 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.

Looks super clean to me, thanks for this big clean! 👏

I'll merge, but next release we need some testers on the :dev tag before releasing to ensure there is no regression

@Pierre-Gilles Pierre-Gilles merged commit a901794 into GladysAssistant:master Nov 25, 2022
@relativeci
Copy link

relativeci bot commented Nov 25, 2022

Job #775: Bundle Size — 7MiB (0%).

a901794(current) vs 760e91a master#750(baseline)

Metrics (no changes)
                 Current
Job #775
     Baseline
Job #750
Initial JS 3.06MiB 3.06MiB
Initial CSS 294.87KiB 294.87KiB
Cache Invalidation 0% 0%
Chunks 52 52
Assets 148 148
Modules 1252 1252
Duplicate Modules 2 2
Duplicate Code 0.03% 0.03%
Packages 106 106
Duplicate Packages 8 8
Total size by type (no changes)
                 Current
Job #775
     Baseline
Job #750
CSS 312.84KiB 312.84KiB
Fonts 93.55KiB 93.55KiB
HTML 13.58KiB 13.58KiB
IMG 1.64MiB 1.64MiB
JS 4.95MiB 4.95MiB
Media 0B 0B
Other 4.95KiB 4.95KiB

View job #775 reportView master branch activity

@VonOx
Copy link
Contributor

VonOx commented Nov 25, 2022

@Pierre-Gilles I will merge in my influxdb branch and deploy to my production.

@VonOx
Copy link
Contributor

VonOx commented Nov 26, 2022

@atrovato @Pierre-Gilles everything fine on my side. 👍

@atrovato atrovato deleted the z2m-clean-code branch December 11, 2022 11:22
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.

3 participants