pull/13/head
Inex Code 2022-08-13 02:32:08 +04:00
parent bb14adb8bc
commit 79bc2668e1
1 changed files with 2 additions and 10 deletions

View File

@ -7,6 +7,7 @@ from selfprivacy_api.services import get_service_by_id, get_services_by_location
from selfprivacy_api.services import Service as ServiceInterface
from selfprivacy_api.utils.block_devices import BlockDevices
def get_usages(root: "StorageVolume") -> list["StorageUsageInterface"]:
"""Get usages of a volume"""
return [
@ -19,6 +20,7 @@ def get_usages(root: "StorageVolume") -> list["StorageUsageInterface"]:
for service in get_services_by_location(root.name)
]
@strawberry.type
class StorageVolume:
"""Stats and basic info about a volume or a system disk."""
@ -34,7 +36,6 @@ class StorageVolume:
usages: list["StorageUsageInterface"] = strawberry.field(resolver=get_usages)
@strawberry.interface
class StorageUsageInterface:
used_space: str
@ -132,13 +133,4 @@ def get_volume_by_id(volume_id: str) -> typing.Optional[StorageVolume]:
model=volume.model,
serial=volume.serial,
type=volume.type,
usages=[
ServiceStorageUsage(
service=service_to_graphql_service(service),
title=service.get_display_name(),
used_space=str(service.get_storage_usage()),
volume=get_volume_by_id(service.get_location()),
)
for service in get_services_by_location(volume.name)
],
)