-
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.
Unify history and distribution API (#124)
- Loading branch information
1 parent
20d57f6
commit fec3d51
Showing
10 changed files
with
127 additions
and
200 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from ..api import rule | ||
from ..api._endpoint import ApiEndpoint | ||
from ..entities._entity import NotFound | ||
from ..entities.distribution import get_distribution_history, DistributionSerializer | ||
from ..entities.summary import Summary | ||
|
||
|
||
class DistributionEntityAPI(ApiEndpoint): | ||
serializer = DistributionSerializer() | ||
|
||
def _get(self, benchmark_id): | ||
try: | ||
summary = Summary.one(id=benchmark_id) | ||
except NotFound: | ||
self.abort_404_not_found() | ||
return get_distribution_history( | ||
summary.run.commit.repository, | ||
summary.run.commit.sha, | ||
summary.case_id, | ||
summary.context_id, | ||
summary.run.machine.hash, | ||
) | ||
|
||
def get(self, benchmark_id): | ||
""" | ||
--- | ||
description: Get benchmark distribution history. | ||
responses: | ||
"200": "DistributionList" | ||
"401": "401" | ||
"404": "404" | ||
parameters: | ||
- name: benchmark_id | ||
in: path | ||
schema: | ||
type: string | ||
tags: | ||
- Distribution | ||
""" | ||
distribution = self._get(benchmark_id) | ||
return self.serializer.many.dump(distribution) | ||
|
||
|
||
distribution_entity_view = DistributionEntityAPI.as_view("distribution") | ||
|
||
rule( | ||
"/distribution/<benchmark_id>/", | ||
view_func=distribution_entity_view, | ||
methods=["GET"], | ||
) |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.