Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/resolvers/revision.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.backends import archive | from swh.graphql.backends import archive | ||||||||
from swh.graphql.utils import utils | from swh.graphql.utils import utils | ||||||||
from swh.model.model import Revision | |||||||||
from swh.model.swhids import CoreSWHID, ObjectType | from swh.model.swhids import CoreSWHID, 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 .release import BaseReleaseNode | from .release import BaseReleaseNode | ||||||||
from .snapshot_branch import BaseSnapshotBranchNode | from .snapshot_branch import BaseSnapshotBranchNode | ||||||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | class LogRevisionConnection(BaseConnection): | ||||||||
Connection resolver for the log (list of revisions) in a revision | Connection resolver for the log (list of revisions) in a revision | ||||||||
""" | """ | ||||||||
obj: BaseRevisionNode | obj: BaseRevisionNode | ||||||||
_node_class = BaseRevisionNode | _node_class = BaseRevisionNode | ||||||||
def _get_paged_result(self) -> PagedResult: | def _get_paged_result(self) -> PagedResult: | ||||||||
# STORAGE-TODO (date in revisionlog is a dict) | |||||||||
log = archive.Archive().get_revision_log([self.obj.swhid.object_id]) | log = archive.Archive().get_revision_log([self.obj.swhid.object_id]) | ||||||||
# Storage is returning a list of dicts instead of model objects | |||||||||
# Following loop is to reverse that operation | |||||||||
ardumontUnsubmitted Not Done Inline Actions
ardumont: | |||||||||
# STORAGE-TODO; remove to_dict from storage.revision_log | |||||||||
log = [Revision.from_dict(rev) for rev in log] | |||||||||
# FIXME, using dummy(local) pagination, move pagination to backend | # FIXME, using dummy(local) pagination, move pagination to backend | ||||||||
# To remove localpagination, just drop the paginated call | # To remove localpagination, just drop the paginated call | ||||||||
# STORAGE-TODO (pagination) | # STORAGE-TODO (pagination) | ||||||||
return utils.paginated(log, self._get_first_arg(), self._get_after_arg()) | return utils.paginated(log, self._get_first_arg(), self._get_after_arg()) |