-
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 #562 from Flowminder/unique_subscriber_counts
Unique subscriber counts
- Loading branch information
Showing
12 changed files
with
131 additions
and
3 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
45 changes: 45 additions & 0 deletions
45
flowmachine/flowmachine/core/server/query_schemas/unique_subscriber_counts.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 UniqueSubscriberCounts | ||
from .base_exposed_query import BaseExposedQuery | ||
from .custom_fields import AggregationUnit | ||
|
||
__all__ = ["UniqueSubscriberCountsSchema", "UniqueSubscriberCountsExposed"] | ||
|
||
|
||
class UniqueSubscriberCountsSchema(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 UniqueSubscriberCountsExposed(**params) | ||
|
||
|
||
class UniqueSubscriberCountsExposed(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 UniqueSubscriberCounts object. | ||
Returns | ||
------- | ||
Query | ||
""" | ||
return UniqueSubscriberCounts( | ||
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
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