-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #590 from Flowminder/total_network_objects
Total Network Objects
- Loading branch information
Showing
11 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
flowmachine/flowmachine/core/server/query_schemas/total_network_objects.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
from marshmallow import Schema, fields, post_load | ||
from marshmallow.validate import OneOf, Length | ||
|
||
from flowmachine.features import TotalNetworkObjects | ||
from .base_exposed_query import BaseExposedQuery | ||
from .custom_fields import AggregationUnit | ||
|
||
__all__ = ["TotalNetworkObjectsSchema", "TotalNetworkObjectsExposed"] | ||
|
||
|
||
class TotalNetworkObjectsSchema(Schema): | ||
|
||
start_date = fields.Date(required=True) | ||
end_date = fields.Date(required=True) | ||
aggregation_unit = AggregationUnit() | ||
|
||
@post_load | ||
def make_query_object(self, params): | ||
return TotalNetworkObjectsExposed(**params) | ||
|
||
|
||
class TotalNetworkObjectsExposed(BaseExposedQuery): | ||
def __init__(self, *, start_date, end_date, aggregation_unit): | ||
# Note: all input parameters need to be defined as attributes on `self` | ||
# so that marshmallow can serialise the object correctly. | ||
self.start_date = start_date | ||
self.end_date = end_date | ||
self.aggregation_unit = aggregation_unit | ||
|
||
@property | ||
def _flowmachine_query_obj(self): | ||
""" | ||
Return the underlying flowmachine daily_location object. | ||
Returns | ||
------- | ||
Query | ||
""" | ||
return TotalNetworkObjects( | ||
start=self.start_date, stop=self.end_date, level=self.aggregation_unit | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters