Skip to content

Commit

Permalink
Remove count fields (#289)
Browse files Browse the repository at this point in the history
* removed count fields
---------

Co-authored-by: Gabriel Fosse <[email protected]>
  • Loading branch information
majesticio and Gabriel Fosse authored Sep 27, 2023
1 parent 8f39d78 commit a36f711
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 17 deletions.
10 changes: 1 addition & 9 deletions openaq_api/openaq_api/v3/models/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ class SensorBase(JsonBase):

class Parameter(ParameterBase):
description: str | None = None
locations_count: int
measurements_count: int


class Country(CountryBase):
Expand All @@ -163,26 +161,20 @@ class Provider(ProviderBase):
datetime_first: datetime
datetime_last: datetime
owner_entity: EntityBase
locations_count: int
measurements_count: int
countries_count: int
parameters: list[ParameterBase]
bbox: GeoJSON | None = None


class Owner(OwnerBase):
locations_count: int = Field(alias='locationsCount')

...

class Instrument(InstrumentBase):
locations_count: int = Field(alias='locationsCount')
is_monitor: bool = Field(alias='isMonitor')
manufacturer: ManufacturerBase


class Manufacturer(ManufacturerBase):
instruments: List[InstrumentBase]
locations_count: int = Field(alias="locationsCount")



Expand Down
1 change: 0 additions & 1 deletion openaq_api/openaq_api/v3/routers/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ async def fetch_instruments(query, db):
WITH locations_summary AS (
SELECT
i.instruments_id
, COUNT(sn.sensor_nodes_id) AS locations_count
FROM
sensor_nodes sn
JOIN
Expand Down
1 change: 0 additions & 1 deletion openaq_api/openaq_api/v3/routers/manufacturers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ async def fetch_manufacturers(query, db):
e.entities_id AS id
, e.full_name AS name
, ARRAY_AGG(DISTINCT (jsonb_build_object('id', i.instruments_id, 'name', i.label))) AS instruments
, COUNT(sn.sensor_nodes_id) AS locations_count
, COUNT(1) OVER() AS found
FROM
sensor_nodes sn
Expand Down
1 change: 0 additions & 1 deletion openaq_api/openaq_api/v3/routers/owners.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ async def fetch_owners(query, db):
sql = f"""
SELECT e.entities_id AS id
, e.full_name AS name
, COUNT(sn.owner_entities_id) AS locations_count
FROM entities e
JOIN sensor_nodes sn ON e.entities_id = sn.owner_entities_id
{query_builder.where()}
Expand Down
2 changes: 0 additions & 2 deletions openaq_api/openaq_api/v3/routers/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ async def fetch_parameters(query, db) -> ParametersResponse:
, p.display_name
, p.units
, p.description
, p.locations_count
, p.measurements_count
{query_builder.total()}
FROM
parameters_view_cached p
Expand Down
3 changes: 0 additions & 3 deletions openaq_api/openaq_api/v3/routers/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ async def fetch_providers(query, db):
, datetime_first
, datetime_last
, datetime_added
, measurements_count
, locations_count
, countries_count
, owner_entity
, parameters
, license
Expand Down

0 comments on commit a36f711

Please sign in to comment.