pyro-api icon indicating copy to clipboard operation
pyro-api copied to clipboard

Adds new table Sites & creates/updates related endpoints

Open fe51 opened this issue 2 months ago • 0 comments

Pitch

The concept of a site appears frequently in discussions with business stakeholders. We also use it implicitly in various contexts (engine, frontend, and streaming).

As a result, we need to reintroduce this concept into the API, specifically in order to be able to:

  1. Display the list of cameras grouped by site
    • Live streaming (currently hardcoded)
    • On the dashboard
  2. Retrieve the IP address of the Pi associated with the site (live streaming) (currently hard-coded)
  3. Retrieve the livestream URL (currently hard-coded)

About the table sites

Below some guideline about the new table (Description is here for the purpose of the issue but not sure if we include it postgresSQL tables)

Do we include a created_at field ? -> To discuss

Column Type Constraints Description
id INT PRIMARY KEY Unique identifier
organization_id INT FOREIGN KEY → organizations(id) Reference to the related organization in organizations table
name VARCHAR TO LIMIT NB OF CHARACTERS ? ? Name of the site
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP Record creation timestamp

What has to be done

  • Add every thing related to the introduction of a the new table Sites in the api (and updates in camera table : removing organisaiton_id foreign key)
  • Endpoints -> To be detailed
    • Update camera endpoint (adding site id) -> For ease of use, but also to ensure continuity of service (before shutting down the old platform, making changes to the new one, and introducing it to users)
    • Create : POST and PATCH (and GET?) endpoints for Site ressource
  • Add migration script
  • Update UML at scripts/dbdiagram.txt
  • Do not forget to add tests :)

Would be happy to discuss it !

fe51 avatar Nov 14 '25 15:11 fe51