Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

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

Merged
whitdog47 merged 7 commits intomainfrom
enhancement/new-endpoint-for-signal-data
Mar 19, 2025
Merged

feat(signals): new endpoint for signal data#5837
whitdog47 merged 7 commits intomainfrom
enhancement/new-endpoint-for-signal-data

Conversation

@whitdog47
Copy link
Copy Markdown
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
Comment thread src/dispatch/signal/models.py Outdated
Comment thread src/dispatch/signal/models.py Outdated
@whitdog47 whitdog47 merged commit fc3887a into main Mar 19, 2025
9 checks passed
@whitdog47 whitdog47 deleted the enhancement/new-endpoint-for-signal-data branch March 19, 2025 18:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants