Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
stop=self.stop,
direction=self.direction,
tables=self.event_types,
subscriber_subset=self.subscriber_subset,
)
class EventCountSchema(BaseQueryWithSamplingSchema):
query_kind = fields.String(validate=OneOf(["event_count"]))
start = ISODateTime(required=True)
stop = ISODateTime(required=True)
direction = fields.String(
required=False, validate=OneOf(["in", "out", "both"]), default="both"
) # TODO: use a globally defined enum for this
event_types = EventTypes()
subscriber_subset = SubscriberSubset()
__model__ = EventCountExposed
stop=self.stop,
direction=self.direction,
tables=self.event_types,
subscriber_subset=self.subscriber_subset,
)
class SubscriberDegreeSchema(BaseQueryWithSamplingSchema):
query_kind = fields.String(validate=OneOf(["subscriber_degree"]))
start = ISODateTime(required=True)
stop = ISODateTime(required=True)
direction = fields.String(
required=False, validate=OneOf(["in", "out", "both"]), default="both"
) # TODO: use a globally defined enum for this
event_types = EventTypes()
subscriber_subset = SubscriberSubset()
__model__ = SubscriberDegreeExposed
Query
"""
return TopUpBalance(
start=self.start_date,
stop=self.end_date,
statistic=self.statistic,
subscriber_subset=self.subscriber_subset,
)
class TopUpBalanceSchema(BaseQueryWithSamplingSchema):
query_kind = fields.String(validate=OneOf(["topup_balance"]))
start_date = ISODateTime(required=True)
end_date = ISODateTime(required=True)
statistic = Statistic()
subscriber_subset = SubscriberSubset()
__model__ = TopUpBalanceExposed
return ParetoInteractions(
start=self.start,
stop=self.stop,
proportion=self.proportion,
tables=self.event_types,
subscriber_subset=self.subscriber_subset,
)
class ParetoInteractionsSchema(BaseQueryWithSamplingSchema):
query_kind = fields.String(validate=OneOf(["pareto_interactions"]))
start = ISODateTime(required=True)
stop = ISODateTime(required=True)
proportion = fields.Float(required=True, validate=Range(min=0.0, max=1.0))
event_types = EventTypes()
subscriber_subset = SubscriberSubset()
__model__ = ParetoInteractionsExposed
stop=self.stop,
statistic=self.statistic,
reference_location=self.reference_location._flowmachine_query_obj,
table=self.event_types,
subscriber_subset=self.subscriber_subset,
)
class DisplacementSchema(BaseQueryWithSamplingSchema):
query_kind = fields.String(validate=OneOf(["displacement"]))
start = ISODateTime(required=True)
stop = ISODateTime(required=True)
statistic = Statistic()
reference_location = fields.Nested(InputToDisplacementSchema, many=False)
event_types = EventTypes()
subscriber_subset = SubscriberSubset()
__model__ = DisplacementExposed
self.start_date,
self.end_date,
spatial_unit=self.aggregation_unit,
table=self.event_types,
subscriber_subset=self.subscriber_subset,
)
)
class UniqueLocationsSchema(AggregationUnitMixin, BaseQueryWithSamplingSchema):
# query_kind parameter is required here for claims validation
query_kind = fields.String(validate=OneOf(["unique_locations"]))
start_date = ISODateTime(required=True)
end_date = ISODateTime(required=True)
event_types = EventTypes()
subscriber_subset = SubscriberSubset()
__model__ = UniqueLocationsExposed
"""
return UniqueLocationCounts(
start=self.start_date,
stop=self.end_date,
spatial_unit=self.aggregation_unit,
tables=self.event_types,
subscriber_subset=self.subscriber_subset,
)
class UniqueLocationCountsSchema(AggregationUnitMixin, BaseSchema):
query_kind = fields.String(validate=OneOf(["unique_location_counts"]))
start_date = ISODateTime(required=True)
end_date = ISODateTime(required=True)
event_types = EventTypes()
subscriber_subset = SubscriberSubset()
__model__ = UniqueLocationCountsExposed
"""
return RadiusOfGyration(
start=self.start_date,
stop=self.end_date,
table=self.event_types,
subscriber_subset=self.subscriber_subset,
)
class RadiusOfGyrationSchema(BaseQueryWithSamplingSchema):
# query_kind parameter is required here for claims validation
query_kind = fields.String(validate=OneOf(["radius_of_gyration"]))
start_date = ISODateTime(required=True)
end_date = ISODateTime(required=True)
event_types = EventTypes()
subscriber_subset = SubscriberSubset()
__model__ = RadiusOfGyrationExposed
self.end_date,
spatial_unit=self.aggregation_unit,
table=self.event_types,
subscriber_subset=self.subscriber_subset,
)
)
)
class ConsecutiveTripsODMatrixSchema(AggregationUnitMixin, BaseSchema):
# query_kind parameter is required here for claims validation
query_kind = fields.String(validate=OneOf(["consecutive_trips_od_matrix"]))
start_date = ISODateTime(required=True)
end_date = ISODateTime(required=True)
event_types = EventTypes()
subscriber_subset = SubscriberSubset()
__model__ = ConsecutiveTripsODMatrixExposed
Query
"""
return TopUpAmount(
start=self.start,
stop=self.stop,
statistic=self.statistic,
subscriber_subset=self.subscriber_subset,
)
class TopUpAmountSchema(BaseQueryWithSamplingSchema):
query_kind = fields.String(validate=OneOf(["topup_amount"]))
start = ISODateTime(required=True)
stop = ISODateTime(required=True)
statistic = Statistic()
subscriber_subset = SubscriberSubset()
__model__ = TopUpAmountExposed