Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/resolvers/person.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 List | |||||
from .base_connection import BaseList | |||||
from .base_node import BaseNode | |||||
from .release import BaseReleaseNode | |||||
from .revision import BaseRevisionNode | |||||
class Person(BaseNode): | |||||
pass | |||||
vlorentz: you can make these types more specific | |||||
def get_person_list(person) -> List[Person]: | |||||
return [person] if person else [] | |||||
class RevisionAuthorList(BaseList): | |||||
""" | |||||
List of revision authors | |||||
""" | |||||
obj: BaseRevisionNode | |||||
Done Inline Actionshere, and the other _get_results below too vlorentz: here, and the other `_get_results` below too | |||||
_node_class = Person | |||||
def _get_results(self) -> List[Person]: | |||||
""" | |||||
Author is a single object in the current data model, | |||||
return it as a list to support future evolutions | |||||
No backend fetching required as the data exists in | |||||
the parent object (revision) | |||||
""" | |||||
return get_person_list(self.obj.author) | |||||
class RevisionCommitterList(BaseList): | |||||
obj: BaseRevisionNode | |||||
_node_class = Person | |||||
def _get_results(self) -> List[Person]: | |||||
""" | |||||
Committer is a single object in the current data model, | |||||
return it as a list to support future evolutions | |||||
No backend fetching required as the data exists in | |||||
the parent object (revision) | |||||
""" | |||||
return get_person_list(self.obj.committer) | |||||
class ReleaseAuthorList(BaseList): | |||||
obj: BaseReleaseNode | |||||
_node_class = Person | |||||
def _get_results(self) -> List[Person]: | |||||
""" | |||||
Author is a single object in the current data model, | |||||
return it as a list to support future evolutions | |||||
No backend fetching required as the data exists in | |||||
the parent object (release) | |||||
""" | |||||
return get_person_list(self.obj.author) |
you can make these types more specific