Skip to content

Commit 9811e50

Browse files
committed
Make reference location extensible too
1 parent c08b405 commit 9811e50

14 files changed

+34
-107
lines changed

flowmachine/flowmachine/core/server/query_schemas/active_at_reference_location_counts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
RedactedActiveAtReferenceLocationCounts,
1616
)
1717

18-
from . import BaseExposedQuery
19-
2018
__all__ = [
2119
"ActiveAtReferenceLocationCountsSchema",
2220
"ActiveAtReferenceLocationCountsExposed",
2321
]
2422

23+
from .base_exposed_query import BaseExposedQuery
24+
2525
from .base_schema import BaseSchema
2626

2727
from .reference_location import ReferenceLocationSchema

flowmachine/flowmachine/core/server/query_schemas/consecutive_trips_od_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from flowmachine.features.location.consecutive_trips_od_matrix import (
1313
ConsecutiveTripsODMatrix,
1414
)
15-
from . import BaseExposedQuery
15+
from .base_exposed_query import BaseExposedQuery
1616
from .base_schema import BaseSchema
1717
from .custom_fields import SubscriberSubset
1818
from .aggregation_unit import AggregationUnit, get_spatial_unit_obj

flowmachine/flowmachine/core/server/query_schemas/flowable_queries.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from flowmachine.core.server.query_schemas.daily_location import DailyLocationSchema
66
from flowmachine.core.server.query_schemas.modal_location import ModalLocationSchema
7+
from flowmachine.core.server.query_schemas.unique_locations import UniqueLocationsSchema
78

89
flowable_queries = {
910
"daily_location": DailyLocationSchema,

flowmachine/flowmachine/core/server/query_schemas/joined_spatial_aggregate.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
from marshmallow_oneofschema import OneOfSchema
1313

1414

15-
from flowmachine.core.server.query_schemas.spatial_aggregate import (
16-
InputToSpatialAggregate,
17-
)
1815
from flowmachine.features.location.joined_spatial_aggregate import (
1916
JoinedSpatialAggregate,
2017
)
@@ -23,6 +20,7 @@
2320
)
2421
from .base_exposed_query import BaseExposedQuery
2522
from .base_schema import BaseSchema
23+
from .reference_location import ReferenceLocationSchema
2624
from .util import get_type_schemas_from_entrypoint
2725

2826

@@ -63,7 +61,7 @@ def _flowmachine_query_obj(self):
6361
class JoinedSpatialAggregateSchema(BaseSchema):
6462
# query_kind parameter is required here for claims validation
6563
query_kind = fields.String(validate=OneOf(["joined_spatial_aggregate"]))
66-
locations = fields.Nested(InputToSpatialAggregate, required=True)
64+
locations = fields.Nested(ReferenceLocationSchema, required=True)
6765
metric = fields.Nested(JoinableMetrics, required=True)
6866
method = fields.String(validate=OneOf(JoinedSpatialAggregate.allowed_methods))
6967

flowmachine/flowmachine/core/server/query_schemas/reference_location.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
from marshmallow_oneofschema import OneOfSchema
6-
7-
from flowmachine.core.server.query_schemas.daily_location import DailyLocationSchema
8-
from flowmachine.core.server.query_schemas.modal_location import ModalLocationSchema
6+
from flowmachine.core.server.query_schemas.util import get_type_schemas_from_entrypoint
97

108

119
class ReferenceLocationSchema(OneOfSchema):
1210
type_field = "query_kind"
13-
type_schemas = {
14-
"daily_location": DailyLocationSchema,
15-
"modal_location": ModalLocationSchema,
16-
}
11+
type_schemas = get_type_schemas_from_entrypoint("reference_location_queries")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
from flowmachine.core.server.query_schemas.daily_location import DailyLocationSchema
6+
from flowmachine.core.server.query_schemas.modal_location import ModalLocationSchema
7+
8+
reference_location_queries = {
9+
"daily_location": DailyLocationSchema,
10+
"modal_location": ModalLocationSchema,
11+
}

flowmachine/flowmachine/core/server/query_schemas/spatial_aggregate.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,23 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
from marshmallow import fields, post_load
5+
from marshmallow import fields
66
from marshmallow.validate import OneOf
7-
from marshmallow_oneofschema import OneOfSchema
87

98
from flowmachine.features.location.redacted_spatial_aggregate import (
109
RedactedSpatialAggregate,
1110
)
1211
from flowmachine.features.location.spatial_aggregate import SpatialAggregate
1312
from .base_exposed_query import BaseExposedQuery
1413
from .base_schema import BaseSchema
15-
from .daily_location import DailyLocationSchema
16-
from .modal_location import ModalLocationSchema
14+
from .reference_location import ReferenceLocationSchema
1715

1816
__all__ = [
1917
"SpatialAggregateSchema",
2018
"SpatialAggregateExposed",
21-
"InputToSpatialAggregate",
2219
]
2320

2421

25-
class InputToSpatialAggregate(OneOfSchema):
26-
type_field = "query_kind"
27-
type_schemas = {
28-
"daily_location": DailyLocationSchema,
29-
"modal_location": ModalLocationSchema,
30-
}
31-
32-
3322
class SpatialAggregateExposed(BaseExposedQuery):
3423
def __init__(self, *, locations):
3524
# Note: all input parameters need to be defined as attributes on `self`
@@ -54,6 +43,6 @@ def _flowmachine_query_obj(self):
5443
class SpatialAggregateSchema(BaseSchema):
5544
# query_kind parameter is required here for claims validation
5645
query_kind = fields.String(validate=OneOf(["spatial_aggregate"]))
57-
locations = fields.Nested(InputToSpatialAggregate, required=True)
46+
locations = fields.Nested(ReferenceLocationSchema, required=True)
5847

5948
__model__ = SpatialAggregateExposed

flowmachine/flowmachine/core/server/query_schemas/trips_od_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from flowmachine.features.location.redacted_trips_od_matrix import RedactedTripsODMatrix
99
from flowmachine.features.utilities.subscriber_locations import SubscriberLocations
1010
from flowmachine.features.location.trips_od_matrix import TripsODMatrix
11-
from . import BaseExposedQuery
11+
from .base_exposed_query import BaseExposedQuery
1212
from .base_schema import BaseSchema
1313
from .custom_fields import SubscriberSubset
1414
from .aggregation_unit import AggregationUnit, get_spatial_unit_obj

flowmachine/flowmachine/core/server/query_schemas/unique_visitor_counts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
from marshmallow import fields, post_load
5+
from marshmallow import fields
66
from marshmallow.validate import OneOf
77

88
from flowmachine.features.location.unique_visitor_counts import UniqueVisitorCounts
@@ -11,7 +11,7 @@
1111

1212
from .unique_subscriber_counts import UniqueSubscriberCountsSchema
1313

14-
from . import BaseExposedQuery
14+
from .base_exposed_query import BaseExposedQuery
1515

1616
__all__ = [
1717
"UniqueVisitorCountsSchema",

flowmachine/flowmachine/core/server/query_schemas/unmoving_at_reference_location_counts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from flowmachine.features.subscriber.unmoving_at_reference_location import (
1515
UnmovingAtReferenceLocation,
1616
)
17-
from . import BaseExposedQuery
17+
from .base_exposed_query import BaseExposedQuery
1818
from .base_schema import BaseSchema
1919
from .reference_location import ReferenceLocationSchema
2020
from .unique_locations import UniqueLocationsSchema

0 commit comments

Comments
 (0)