-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add usage related stuff + fix popularity related stuff
- Loading branch information
Showing
24 changed files
with
1,005 additions
and
237 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
10 changes: 10 additions & 0 deletions
10
backend/src/offspot_metrics_backend/business/exceptions.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,10 @@ | ||
class TooWideUsageError(Exception): | ||
"""Exception raised when usage range is wider than expected number of minutes""" | ||
|
||
pass | ||
|
||
|
||
class WrongInputTypeError(Exception): | ||
"""Exception raised when input received does not match expectations""" | ||
|
||
pass |
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
41 changes: 41 additions & 0 deletions
41
backend/src/offspot_metrics_backend/business/indicators/total_usage.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,41 @@ | ||
from typing import cast | ||
|
||
from offspot_metrics_backend.business.indicators.dimensions import DimensionsValues | ||
from offspot_metrics_backend.business.indicators.indicator import Indicator | ||
from offspot_metrics_backend.business.indicators.recorder import ( | ||
Recorder, | ||
UsageRecorder, | ||
) | ||
from offspot_metrics_backend.business.inputs.input import Input | ||
from offspot_metrics_backend.business.inputs.package import PackageRequest | ||
|
||
|
||
class TotalUsageOverall(Indicator): | ||
"""An indicator counting usage activity on all packages""" | ||
|
||
unique_id = 1005 | ||
|
||
def can_process_input(self, input_: Input) -> bool: | ||
return isinstance(input_, PackageRequest) | ||
|
||
def get_new_recorder(self) -> Recorder: | ||
return UsageRecorder() | ||
|
||
def get_dimensions_values(self, input_: Input) -> DimensionsValues: # noqa: ARG002 | ||
return DimensionsValues(None, None, None) | ||
|
||
|
||
class TotalUsageByPackage(Indicator): | ||
"""An indicator counting usage activity by packages""" | ||
|
||
unique_id = 1006 | ||
|
||
def can_process_input(self, input_: Input) -> bool: | ||
return isinstance(input_, PackageRequest) | ||
|
||
def get_new_recorder(self) -> Recorder: | ||
return UsageRecorder() | ||
|
||
def get_dimensions_values(self, input_: Input) -> DimensionsValues: | ||
input_ = cast(PackageRequest, input_) | ||
return DimensionsValues(input_.package_title, None, None) |
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
Oops, something went wrong.