Skip to content

Commit

Permalink
add entitiy_kind
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnnsrs committed Aug 13, 2024
1 parent 5fae3ad commit df45448
Show file tree
Hide file tree
Showing 32 changed files with 2,519 additions and 2,494 deletions.
47 changes: 47 additions & 0 deletions core/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,17 @@ def filter_ids(self, queryset, info):
return queryset.filter(id__in=self.ids)


@strawberry.django.filter(models.EntityRelationKind)
class EntityRelationKindFilter(IDFilterMixin, SearchFilterMixin):
id: auto
search: str | None


def filter_search(self, queryset, info):
if self.search is None:
return queryset
return queryset.filter(kind__label__contains=self.search)


@strawberry.django.filter(models.EntityKind)
class EntityKindFilter(IDFilterMixin, SearchFilterMixin):
Expand Down Expand Up @@ -280,6 +291,38 @@ def filter_search(self, queryset, info):
print("Found", x)
return x

@strawberry.django.filter(models.RelationMetric)
class RelationMetricFilter(IDFilterMixin):
id: auto
kind: strawberry.ID | None = None
kind_label: str | None = None
data_kind: enums.MetricDataType | None = None
search: str | None = None

def filter_kind(self, queryset, info):
if self.kind is None:
return queryset
return queryset.filter(data_kind=self.kind)

def filter_data_kind(self, queryset, info):
if self.data_kind is None:
return queryset
return queryset.filter(data_kind=self.data_kind)

def filter_kind_name(self, queryset, info):
if self.kind_label is None:
return queryset
return queryset.filter(kind__label=self.kind_label)

def filter_search(self, queryset, info):
if self.search is None:
return queryset

print("Searching for", self.search)
print("Queryset", queryset)
x = queryset.filter(kind__label__search=self.search)
print("Found", x)
return x

@strawberry.django.filter(models.EntityGroup)
class EntityGroupFilter(IDFilterMixin, SearchFilterMixin):
Expand Down Expand Up @@ -334,6 +377,10 @@ class SpecimenFilter(IDFilterMixin, SearchFilterMixin):
class ProtocolFilter(IDFilterMixin, SearchFilterMixin):
id: auto

@strawberry.django.filter(models.ProtocolStepMapping)
class ProtocolStepMappingFilter(IDFilterMixin, SearchFilterMixin):
id: auto

@strawberry.django.filter(models.Experiment)
class ExperimentFilter(IDFilterMixin, SearchFilterMixin):
id: auto
Expand Down
Loading

0 comments on commit df45448

Please sign in to comment.