Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/interface.py
# Copyright (C) 2015-2021 The Software Heritage developers | # Copyright (C) 2015-2021 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 | from typing import Any, Dict, Iterable, List, Optional, Tuple | ||||
from uuid import UUID | from uuid import UUID | ||||
from typing_extensions import Protocol, runtime_checkable | from typing_extensions import Protocol, runtime_checkable | ||||
from swh.core.api import remote_api_endpoint | from swh.core.api import remote_api_endpoint | ||||
from swh.scheduler.model import ( | from swh.scheduler.model import ( | ||||
ListedOrigin, | ListedOrigin, | ||||
ListedOriginPageToken, | ListedOriginPageToken, | ||||
▲ Show 20 Lines • Show All 326 Lines • ▼ Show 20 Lines | def origin_visit_stats_upsert( | ||||
self, origin_visit_stats: Iterable[OriginVisitStats] | self, origin_visit_stats: Iterable[OriginVisitStats] | ||||
) -> None: | ) -> None: | ||||
"""Create a new origin visit stats | """Create a new origin visit stats | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("visit_stats/get") | @remote_api_endpoint("visit_stats/get") | ||||
def origin_visit_stats_get( | def origin_visit_stats_get( | ||||
self, url: str, visit_type: str | self, ids: Iterable[Tuple[str, str]] | ||||
) -> Optional[OriginVisitStats]: | ) -> List[OriginVisitStats]: | ||||
"""Retrieve the stats for an origin with a given visit type""" | """Retrieve the stats for an origin with a given visit type | ||||
If some visit_stats are not found, they are filtered out of the result. So the | |||||
output list may be of length inferior to the length of the input list. | |||||
""" | |||||
... | ... | ||||
@remote_api_endpoint("scheduler_metrics/update") | @remote_api_endpoint("scheduler_metrics/update") | ||||
def update_metrics( | def update_metrics( | ||||
self, | self, | ||||
lister_id: Optional[UUID] = None, | lister_id: Optional[UUID] = None, | ||||
timestamp: Optional[datetime.datetime] = None, | timestamp: Optional[datetime.datetime] = None, | ||||
) -> List[SchedulerMetrics]: | ) -> List[SchedulerMetrics]: | ||||
Show All 22 Lines |