Changeset View
Changeset View
Standalone View
Standalone View
swh/search/journal_client.py
# Copyright (C) 2018-2021 The Software Heritage developers | # Copyright (C) 2018-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 logging | import logging | ||||
import sys | |||||
from typing import Dict, Optional | from typing import Dict, Optional | ||||
from swh.model.model import TargetType | from swh.model.model import TargetType | ||||
from swh.storage.algos.snapshot import snapshot_get_all_branches | from swh.storage.algos.snapshot import snapshot_get_all_branches | ||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
EXPECTED_MESSAGE_TYPES = { | EXPECTED_MESSAGE_TYPES = { | ||||
"origin", | "origin", | ||||
"origin_visit_status", | "origin_visit_status", | ||||
"origin_intrinsic_metadata", | "origin_intrinsic_metadata", | ||||
} | } | ||||
def fetch_last_revision_release_date( | def fetch_last_revision_release_date( | ||||
snapshot_id: bytes, storage: StorageInterface | snapshot_id: bytes, storage: StorageInterface | ||||
) -> Dict[str, str]: | ) -> Dict[str, str]: | ||||
if "pytest" not in sys.modules: | |||||
# FIXME: This function is too slow to be reasonably used in the journal-client | |||||
# (at least the main one), we need to figure out a solution before this can | |||||
# be enabled again. | |||||
return {} | |||||
if not snapshot_id: | if not snapshot_id: | ||||
return {} | return {} | ||||
snapshot = snapshot_get_all_branches(storage, snapshot_id) | snapshot = snapshot_get_all_branches(storage, snapshot_id) | ||||
if not snapshot: | if not snapshot: | ||||
return {} | return {} | ||||
branches = snapshot.branches.values() | branches = snapshot.branches.values() | ||||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |