Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/resolvers/directory_entry.py
Show All 11 Lines | |||||
class BaseDirectoryEntryNode(BaseNode): | class BaseDirectoryEntryNode(BaseNode): | ||||
@property | @property | ||||
def target_hash(self): # for DirectoryNode | def target_hash(self): # for DirectoryNode | ||||
return self._node.target | return self._node.target | ||||
@property | @property | ||||
def targetType(self): # To support the schema naming convention | def targetType(self): # To support the schema naming convention | ||||
return self._node.type | mapping = {"file": "content", "dir": "directory", "rev": "revision"} | ||||
return mapping.get(self._node.type) | |||||
class DirectoryEntryNode(BaseDirectoryEntryNode): | class DirectoryEntryNode(BaseDirectoryEntryNode): | ||||
""" | """ | ||||
Node resolver for a directory entry requested with a | Node resolver for a directory entry requested with a | ||||
directory SWHID and a relative path | directory SWHID and a relative path | ||||
""" | """ | ||||
Show All 17 Lines | class DirectoryEntryConnection(BaseConnection): | ||||
_node_class = BaseDirectoryEntryNode | _node_class = BaseDirectoryEntryNode | ||||
def _get_paged_result(self) -> PagedResult: | def _get_paged_result(self) -> PagedResult: | ||||
# 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 | # STORAGE-TODO | ||||
entries = self.archive.get_directory_entries(self.obj.swhid.object_id).results | entries = self.archive.get_directory_entries(self.obj.swhid.object_id).results | ||||
name_include = self.kwargs.get("nameInclude") | |||||
if name_include is not None: | |||||
# STORAGE-TODO, move this filter to swh-storage | |||||
entries = [ | |||||
anlambert: you should call lower before encode here | |||||
x for x in entries if name_include.lower().encode() in x.name.lower() | |||||
] | |||||
return utils.paginated(entries, self._get_first_arg(), self._get_after_arg()) | return utils.paginated(entries, self._get_first_arg(), self._get_after_arg()) |
you should call lower before encode here