Skip to content

Commit

Permalink
Added distinct filter to STA engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Lippold authored and Ken Lippold committed Oct 3, 2024
1 parent 395fe4a commit a6bd510
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 29 deletions.
2 changes: 2 additions & 0 deletions stapi/engine/components/datastreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def get_datastreams(
order_by=ordering
)

datastreams = datastreams.distinct()

if get_count:
count = datastreams.count()
else:
Expand Down
2 changes: 2 additions & 0 deletions stapi/engine/components/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def get_locations(
order_by=ordering
)

things = things.distinct()

if get_count:
count = things.count()
else:
Expand Down
4 changes: 2 additions & 2 deletions stapi/engine/components/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ def get_observations(
order_by=ordering
)

observations = observations.distinct()

if get_count:
count = observations.count()
else:
count = None

observations = observations.distinct()

if datastream_ids:
observations = self.apply_rank(
component=ObservationSchema,
Expand Down
2 changes: 2 additions & 0 deletions stapi/engine/components/observed_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def get_observed_properties(
order_by=ordering
)

observed_properties = observed_properties.distinct()

if get_count:
count = observed_properties.count()
else:
Expand Down
2 changes: 2 additions & 0 deletions stapi/engine/components/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def get_sensors(
order_by=ordering
)

sensors = sensors.distinct()

if get_count:
count = sensors.count()
else:
Expand Down
2 changes: 2 additions & 0 deletions stapi/engine/components/things.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def get_things(
order_by=ordering
)

things = things.distinct()

if get_count:
count = things.count()
else:
Expand Down
52 changes: 25 additions & 27 deletions tests/test_sensorthings_endpoints.py

Large diffs are not rendered by default.

0 comments on commit a6bd510

Please sign in to comment.