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

feat(signals): new endpoint for signal data #5837

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

whitdog47
Copy link
Contributor

This pull request introduces a new feature to the signal module, allowing users to retrieve signal data based on a given entity name and type. The changes include the addition of a new endpoint, the necessary backend logic to support this functionality, and comprehensive tests to ensure reliability.

Key Changes:

  1. New Model:

    • Added SignalData model to encapsulate the response structure for the new endpoint, including fields for the number of signals alerted, snoozed, and the status of snoozes (active or expired).
  2. Service Layer:

    • Implemented get_signal_data function in service.py to query the database for signal data based on the provided entity name and type.
    • Utilized JSONB operations to filter signals associated with the specified entity.
    • Added logic to calculate active and expired snoozes, as well as signals with and without snooze actions.
    • Introduced a parameter num_days to allow filtering signals based on a date threshold.
  3. API Endpoint:

    • Added a new GET endpoint /data in views.py to expose the signal data retrieval functionality.
    • The endpoint accepts query parameters for entity_value, entity_type_id, and num_days.
  4. Testing:

    • Added comprehensive tests in test_signal_data_service.py to verify the functionality of get_signal_data.
    • Tests cover basic functionality, date-based filtering, snooze filters, expired snooze filters, and scenarios where no signals are found.
    • Ensured that the tests validate the correct calculation of signal counts and snooze statuses.
  5. Enhancements:

    • Improved query performance by leveraging SQLAlchemy's JSONB capabilities and efficient filtering.
    • Enhanced the API's flexibility by allowing optional date-based filtering.

@whitdog47 whitdog47 added the enhancement New feature or request label Mar 17, 2025
@whitdog47 whitdog47 self-assigned this Mar 17, 2025
@whitdog47 whitdog47 changed the title Enhancement/new endpoint for signal data feat(signals): new endpoint for signal data Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant