Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jgadling committed Jan 7, 2025
1 parent 731ee9f commit d830735
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
10 changes: 8 additions & 2 deletions apiv2/platformics/graphql_api/core/strawberry_helpers.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
from typing import Tuple

from strawberry.types.nodes import SelectedField

from platformics.graphql_api.core.errors import PlatformicsError
from typing import Tuple


def filter_meta_fields(selections: list[SelectedField]) -> list[SelectedField]:
return [item for item in selections if not item.name.startswith("__")]


def get_field_by_name(selections: list[SelectedField], item_name: str) -> SelectedField:
for item in selections:
if item.name == item_name:
return item


def exclude_fields_by_name(selections: list[SelectedField], item_name: str) -> list[SelectedField]:
return [item for item in selections if item.name != item_name]


def get_nested_selected_fields(selected_fields: list[SelectedField]) -> list[SelectedField]:
selected_fields = selected_fields[0].selections
selections = []
Expand All @@ -32,4 +38,4 @@ def get_aggregate_selections(selected_fields: list[SelectedField]) -> Tuple[list
if not aggregate_selections:
raise PlatformicsError("No aggregate functions selected")

return aggregate_selections, groupby_selections
return aggregate_selections, groupby_selections
1 change: 1 addition & 0 deletions apiv2/tests/test_aggregate_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from platformics.database.connect import SyncDB
from platformics.test_infra.factories.base import SessionStorage
from test_infra.factories.dataset import DatasetFactory
from test_infra.factories.deposition import DepositionFactory
from test_infra.factories.run import RunFactory

date_now = datetime.datetime.now()
Expand Down
2 changes: 0 additions & 2 deletions apiv2/tests/test_gql_meta_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

from platformics.database.connect import SyncDB
from platformics.test_infra.factories.base import SessionStorage
from test_infra.factories.dataset import DatasetFactory
from test_infra.factories.deposition import DepositionFactory
from test_infra.factories.run import RunFactory

date_now = datetime.datetime.now()

Expand Down

0 comments on commit d830735

Please sign in to comment.