Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/resolvers/snapshot.py
# Copyright (C) 2022 The Software Heritage developers | # Copyright (C) 2022 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 | ||||
from typing import Union | from typing import Union | ||||
from swh.graphql.utils import utils | from swh.graphql.utils import utils | ||||
from swh.model.model import Snapshot | from swh.model.model import Snapshot | ||||
from swh.model.swhids import ObjectType | from swh.model.swhids import ObjectType | ||||
from swh.storage.interface import PagedResult | from swh.storage.interface import PagedResult | ||||
from .base_connection import BaseConnection | from .base_connection import BaseConnection | ||||
from .base_node import BaseSWHNode | from .base_node import BaseSWHNode | ||||
from .origin import OriginNode | from .origin import OriginNode | ||||
from .search import SearchResultNode | |||||
from .visit_status import BaseVisitStatusNode | from .visit_status import BaseVisitStatusNode | ||||
class BaseSnapshotNode(BaseSWHNode): | class BaseSnapshotNode(BaseSWHNode): | ||||
""" | """ | ||||
Base resolver for all the snapshot nodes | Base resolver for all the snapshot nodes | ||||
""" | """ | ||||
Show All 39 Lines | |||||
class TargetSnapshotNode(BaseSnapshotNode): | class TargetSnapshotNode(BaseSnapshotNode): | ||||
""" | """ | ||||
Node resolver for a snapshot requested as a target | Node resolver for a snapshot requested as a target | ||||
""" | """ | ||||
from .snapshot_branch import BaseSnapshotBranchNode | from .snapshot_branch import BaseSnapshotBranchNode | ||||
obj: Union[BaseVisitStatusNode, BaseSnapshotBranchNode] | obj: Union[SearchResultNode, BaseSnapshotBranchNode] | ||||
def _get_node_data(self): | def _get_node_data(self): | ||||
snapshot_id = self.obj.target_hash | snapshot_id = self.obj.target_hash | ||||
return self._get_snapshot_by_id(snapshot_id) | return self._get_snapshot_by_id(snapshot_id) | ||||
class OriginSnapshotConnection(BaseConnection): | class OriginSnapshotConnection(BaseConnection): | ||||
""" | """ | ||||
Show All 14 Lines |