Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/interface.py
# Copyright (C) 2015-2020 The Software Heritage developers | # Copyright (C) 2015-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import datetime | import datetime | ||||
from typing import Any, Dict, Iterable, List, Optional, Union | from typing import Any, Dict, Iterable, List, Optional, Tuple, Union | ||||
from swh.core.api import remote_api_endpoint | from swh.core.api import remote_api_endpoint | ||||
from swh.model.identifiers import SWHID | from swh.model.identifiers import SWHID | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
Content, | Content, | ||||
Directory, | Directory, | ||||
Origin, | Origin, | ||||
OriginVisit, | OriginVisit, | ||||
▲ Show 20 Lines • Show All 891 Lines • ▼ Show 20 Lines | ) -> Optional[OriginVisitStatus]: | ||||
Returns: | Returns: | ||||
The OriginVisitStatus matching the criteria | The OriginVisitStatus matching the criteria | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("origin/visit/get_random") | @remote_api_endpoint("origin/visit/get_random") | ||||
def origin_visit_get_random(self, type: str) -> Optional[Dict[str, Any]]: | def origin_visit_get_random( | ||||
self, type: str | |||||
) -> Optional[Tuple[OriginVisit, OriginVisitStatus]]: | |||||
"""Randomly select one successful origin visit with <type> | """Randomly select one successful origin visit with <type> | ||||
vlorentz: meh.
Could you rename the endpoint to origin_visit_status_get_random, if we want to return a… | |||||
Done Inline ActionsI keep the Tuple as result though, right. Because you know, the origin-visit holds the type the status can't have. ardumont: I keep the Tuple as result though, right.
Because you know, the origin-visit holds the type… | |||||
Not Done Inline ActionsI guess. Or maybe we should move the type to the status... vlorentz: I guess. Or maybe we should move the type to the status... | |||||
Done Inline Actionslol at the ... That leaves a taste like back to square one ¯\_(ツ)_/¯ ;) ardumont: lol at the `...`
That leaves a taste like `back to square one` ¯\_(ツ)_/¯ ;)
| |||||
made in the last 3 months. | made in the last 3 months. | ||||
Returns: | Returns: | ||||
dict representing an origin visit, in the same format as | One random tuple of (OriginVisit, OriginVisitStatus) matching the | ||||
:py:meth:`origin_visit_get`. | selection criteria | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("object/find_by_sha1_git") | @remote_api_endpoint("object/find_by_sha1_git") | ||||
def object_find_by_sha1_git(self, ids): | def object_find_by_sha1_git(self, ids): | ||||
"""Return the objects found with the given ids. | """Return the objects found with the given ids. | ||||
▲ Show 20 Lines • Show All 344 Lines • Show Last 20 Lines |
meh.
Could you rename the endpoint to origin_visit_status_get_random, if we want to return a status?