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

Migrating device-monitoring into device-registry microservice #4017

Merged
merged 15 commits into from
Jan 9, 2025

Conversation

Baalmart
Copy link
Contributor

@Baalmart Baalmart commented Dec 6, 2024

Description

Merging device-monitoring into device-registry microservice

Changes Made

  • Merging device-monitoring into device-registry microservice
  • New cronjobs for generating the statistical data
  • Creation of new collections to support the new functionality
  • New endpoints created to enable access to the statistical data
  • New corresponding controller files
  • New corresponding util files
  • New corresponding model files.

Testing

  • Tested locally
  • Tested against staging environment
  • Relevant tests passed: [List test names]

Affected Services

  • Which services were modified:
    • device-registry

Endpoints Ready for Testing

  • New endpoints ready for testing:

FEEDS

  • GET: /feeds/recent/{DEVICE_NUMBER}
  • GET: /feeds/transform/recent

UPTIME

  • GET: /uptime/status
  • GET: /uptime/network
  • GET: /uptime/device
  • GET: /uptime/battery
  • GET /uptime/leaderboard

COLLOCATION:

  • POST: /collocations/
  • DELETE: /collocations/
  • PATCH: /collocations/reset
  • GET: /collocations/
  • GET: /collocations/summary
  • GET: /collocations/data
  • GET: /collocations/results
  • GET: /collocations/data-completeness
  • GET: /collocations/statistics
  • GET: /collocations/intra

API Documentation Updated?

  • Yes, API documentation was updated
  • No, API documentation does not need updating

Additional Notes

Merging device-monitoring into device-registry microservice

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced scheduled jobs for device status checks, uptime monitoring, and network analysis.
    • Added RESTful API routes for managing collocation and uptime data.
    • Implemented validation middleware for collocation and uptime requests.
    • Enhanced device and network uptime data management with new utility functions.
    • Added new classes and utility functions for collocation data analysis and processing.
  • Bug Fixes

    • Improved error handling across various modules to ensure robust operations.
  • Documentation

    • Updated configuration files for development, production, and staging environments with new BigQuery properties.
  • Tests

    • Added unit tests for new features and validation logic to ensure functionality and reliability.

Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This pull request introduces a comprehensive suite of functionality for monitoring and analyzing device performance in the AirQo network. The changes span multiple components, including job schedulers, controllers, models, routes, and utilities, focusing on device status tracking, uptime calculation, and collocation data management. The implementation leverages technologies like BigQuery, Mongoose, and node-cron to provide detailed insights into device health, network performance, and sensor correlations.

Changes

File/Directory Change Summary
src/device-registry/bin/jobs/ Added new job schedulers for device status checks, hourly status checks, device uptime, and network uptime analysis
src/device-registry/config/environments/ Updated configuration files with new BigQuery-related environment variables for development, production, and staging
src/device-registry/config/global/envs.js Introduced new environment variables for data completeness and correlation thresholds
src/device-registry/controllers/ Created new controllers for collocation, feed, and uptime management
src/device-registry/models/ Added models for CollocationBatch, DeviceBattery, DeviceStatus, DeviceUptime, and NetworkUptime
src/device-registry/routes/v2/ Implemented new routes for uptime, feeds, and collocations
src/device-registry/utils/ Developed utility modules for collocation, feed, uptime, and date manipulation
src/device-registry/package.json Added Lodash as a new dependency
src/device-registry/validators/ Created validation middleware for collocation and uptime routes

Possibly related PRs

Suggested Reviewers

  • BenjaminSsempala
  • Mnoble-19
  • wabinyai

Poem

🌐 Devices dance in digital light,
Tracking status, day and night.
Sensors whisper their tales so bright,
Of uptime's rhythm, data's might.
A network's pulse, now clear and tight! 📊


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c00e2ed and db75ec3.

⛔ Files ignored due to path filters (1)
  • src/device-registry/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (28)
  • src/device-registry/bin/jobs/device-status-check-job.js (1 hunks)
  • src/device-registry/bin/jobs/device-status-hourly-check-job.js (1 hunks)
  • src/device-registry/bin/jobs/device-uptime-job.js (1 hunks)
  • src/device-registry/bin/jobs/network-analysis-uptime-job.js (1 hunks)
  • src/device-registry/config/environments/development.js (1 hunks)
  • src/device-registry/config/environments/production.js (1 hunks)
  • src/device-registry/config/environments/staging.js (1 hunks)
  • src/device-registry/config/global/envs.js (1 hunks)
  • src/device-registry/controllers/create-collocation.js (1 hunks)
  • src/device-registry/controllers/create-feed.js (1 hunks)
  • src/device-registry/controllers/create-uptime.js (1 hunks)
  • src/device-registry/models/CollocationBatch.js (1 hunks)
  • src/device-registry/models/DeviceBattery.js (1 hunks)
  • src/device-registry/models/DeviceStatus.js (1 hunks)
  • src/device-registry/models/DeviceUptime.js (1 hunks)
  • src/device-registry/models/NetworkUptime.js (1 hunks)
  • src/device-registry/package.json (1 hunks)
  • src/device-registry/routes/v2/collocations.js (1 hunks)
  • src/device-registry/routes/v2/feeds.js (1 hunks)
  • src/device-registry/routes/v2/index.js (1 hunks)
  • src/device-registry/routes/v2/uptime.js (1 hunks)
  • src/device-registry/utils/collocation-types.js (1 hunks)
  • src/device-registry/utils/create-collocation.js (1 hunks)
  • src/device-registry/utils/create-feed.js (1 hunks)
  • src/device-registry/utils/create-uptime.js (1 hunks)
  • src/device-registry/utils/date.js (3 hunks)
  • src/device-registry/validators/collocation.validators.js (1 hunks)
  • src/device-registry/validators/uptime.validators.js (1 hunks)

Finishing Touches

  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Baalmart Baalmart marked this pull request as draft December 6, 2024 12:13
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 13.24063% with 1435 lines in your changes missing coverage. Please review.

Project coverage is 11.87%. Comparing base (c00e2ed) to head (db75ec3).
Report is 105 commits behind head on staging.

Files with missing lines Patch % Lines
src/device-registry/utils/create-collocation.js 3.38% 399 Missing ⚠️
.../device-registry/controllers/create-collocation.js 4.10% 280 Missing ⚠️
src/device-registry/utils/create-uptime.js 8.42% 163 Missing ⚠️
src/device-registry/utils/create-feed.js 7.36% 151 Missing ⚠️
src/device-registry/controllers/create-uptime.js 10.86% 82 Missing ⚠️
src/device-registry/models/DeviceBattery.js 20.22% 71 Missing ⚠️
src/device-registry/models/NetworkUptime.js 27.69% 47 Missing ⚠️
src/device-registry/models/DeviceStatus.js 31.34% 46 Missing ⚠️
src/device-registry/controllers/create-feed.js 17.30% 43 Missing ⚠️
src/device-registry/models/DeviceUptime.js 30.50% 41 Missing ⚠️
... and 5 more
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           staging    #4017      +/-   ##
===========================================
+ Coverage    11.73%   11.87%   +0.14%     
===========================================
  Files          116      132      +16     
  Lines        15624    17278    +1654     
  Branches       328      328              
===========================================
+ Hits          1833     2052     +219     
- Misses       13791    15226    +1435     
Files with missing lines Coverage Δ
src/device-registry/routes/v2/collocations.js 100.00% <100.00%> (ø)
src/device-registry/routes/v2/uptime.js 87.50% <87.50%> (ø)
...vice-registry/validators/collocation.validators.js 34.61% <34.61%> (ø)
...rc/device-registry/validators/uptime.validators.js 31.57% <31.57%> (ø)
src/device-registry/models/CollocationBatch.js 38.46% <38.46%> (ø)
src/device-registry/utils/collocation-types.js 2.77% <2.77%> (ø)
src/device-registry/models/DeviceUptime.js 30.50% <30.50%> (ø)
src/device-registry/controllers/create-feed.js 17.30% <17.30%> (ø)
src/device-registry/models/DeviceStatus.js 31.34% <31.34%> (ø)
src/device-registry/models/NetworkUptime.js 27.69% <27.69%> (ø)
... and 6 more

@Baalmart Baalmart changed the title Merging device-monitoring into device-registry microservice Migrating device-monitoring into device-registry microservice Dec 9, 2024
Copy link
Contributor

Device registry changes in this PR available for preview here

Copy link
Contributor

github-actions bot commented Jan 4, 2025

Device registry changes in this PR available for preview here

Copy link
Contributor

github-actions bot commented Jan 4, 2025

Device registry changes in this PR available for preview here

1 similar comment
Copy link
Contributor

github-actions bot commented Jan 4, 2025

Device registry changes in this PR available for preview here

Copy link
Contributor

github-actions bot commented Jan 4, 2025

Device registry changes in this PR available for preview here

Copy link
Contributor

github-actions bot commented Jan 5, 2025

Device registry changes in this PR available for preview here

@Baalmart Baalmart marked this pull request as ready for review January 9, 2025 05:51
@Baalmart Baalmart merged commit 4a24d39 into staging Jan 9, 2025
52 checks passed
@Baalmart Baalmart deleted the migrating-device-monitoring branch January 9, 2025 05:52
@Baalmart Baalmart mentioned this pull request Jan 9, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant