-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sequences): create a table for easy detection aggregation (#405)
* feat(models): add a new table called streams * feat(config): add stream params to dynamic creation * feat(streams): implement creation and update when detection are created * fix(detections): update the query to fetch detections * refactor(sequence): rename stream into sequence * feat(crud): improve filters * feat(detections): sequence are now azimuth specific * fix(api): update crud getter * ci(labeler): add sequences * feat(sequences): add fetch of sequences * test(e2e): ensured sequence was created * test(sequences): add test suite * test(e2e): fix typo * test(confteat): fix mock data * test(e2e): fix typo * test(detections): fix unit tests * feat(sequences): add DELETE route * test(sequences): update table name
- Loading branch information
Showing
16 changed files
with
302 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (C) 2025, Pyronear. | ||
|
||
# This program is licensed under the Apache License 2.0. | ||
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details. | ||
|
||
from typing import List | ||
|
||
from fastapi import APIRouter, Depends, Path, Security, status | ||
|
||
from app.api.dependencies import get_jwt, get_sequence_crud | ||
from app.crud import SequenceCRUD | ||
from app.models import Sequence, UserRole | ||
from app.schemas.login import TokenPayload | ||
from app.services.telemetry import telemetry_client | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/", status_code=status.HTTP_200_OK, summary="Fetch all the sequences") | ||
async def fetch_sequences( | ||
sequences: SequenceCRUD = Depends(get_sequence_crud), | ||
token_payload: TokenPayload = Security(get_jwt, scopes=[UserRole.ADMIN]), | ||
) -> List[Sequence]: | ||
telemetry_client.capture(token_payload.sub, event="sequence-fetch") | ||
return [elt for elt in await sequences.fetch_all()] | ||
|
||
|
||
@router.delete("/{sequence_id}", status_code=status.HTTP_200_OK, summary="Delete a sequence") | ||
async def delete_sequence( | ||
sequence_id: int = Path(..., gt=0), | ||
sequences: SequenceCRUD = Depends(get_sequence_crud), | ||
token_payload: TokenPayload = Security(get_jwt, scopes=[UserRole.ADMIN]), | ||
) -> None: | ||
telemetry_client.capture(token_payload.sub, event="sequence-deletion", properties={"sequence_id": sequence_id}) | ||
await sequences.delete(sequence_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (C) 2025, Pyronear. | ||
|
||
# This program is licensed under the Apache License 2.0. | ||
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details. | ||
|
||
from sqlmodel.ext.asyncio.session import AsyncSession | ||
|
||
from app.crud.base import BaseCRUD | ||
from app.models import Sequence | ||
from app.schemas.sequences import SequenceUpdate | ||
|
||
__all__ = ["SequenceCRUD"] | ||
|
||
|
||
class SequenceCRUD(BaseCRUD[Sequence, Sequence, SequenceUpdate]): | ||
def __init__(self, session: AsyncSession) -> None: | ||
super().__init__(session, Sequence) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (C) 2020-2025, Pyronear. | ||
|
||
# This program is licensed under the Apache License 2.0. | ||
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details. | ||
|
||
from datetime import datetime | ||
|
||
from pydantic import BaseModel | ||
|
||
__all__ = ["SequenceUpdate"] | ||
|
||
|
||
# Accesses | ||
class SequenceUpdate(BaseModel): | ||
last_seen_at: datetime |
Oops, something went wrong.