Fakultas Ilmu Komputer UI

Commit f5797bf7 authored by abdurrafiarief's avatar abdurrafiarief Committed by hashlash
Browse files

[GREEN] Added feature search datasource by picName

parent 6028d9ab
Pipeline #51751 passed with stage
in 19 minutes and 10 seconds
......@@ -16,7 +16,8 @@ class MustahikQuery(graphene.ObjectType):
mustahik = graphene.Field(MustahikType, id=graphene.ID(required=True))
data_sources = graphene.List(
DataSourceType, category=graphene.String(),
name_contains=graphene.String()
name_contains=graphene.String(),
picName_contains=graphene.String()
)
data_source = graphene.Field(DataSourceType, id=graphene.ID(required=True))
......@@ -39,9 +40,13 @@ class MustahikQuery(graphene.ObjectType):
def resolve_mustahik(self, info, id):
return Mustahik.objects.get(pk=id)
def resolve_data_source(self, info, id):
return DataSource.objects.get(pk=id)
def resolve_data_sources(self, info, **kwargs):
category = kwargs.get('category', None)
query = kwargs.get('name_contains', None)
picName = kwargs.get('picName_contains', None)
filter_query = Q()
if category:
filter_query &= Q(category=category)
......@@ -56,7 +61,14 @@ class MustahikQuery(graphene.ObjectType):
| Q(datasourcewarga__village__icontains=query)
)
if picName:
filter_query &= (
Q(datasourcepekerja__pic_name__icontains=picName)
| Q(datasourceinstitusi__pic_name__icontains=picName)
| Q(datasourcewarga__pic_name__icontains=picName)
)
return DataSource.objects.filter(filter_query)
def resolve_data_source(self, info, id):
return DataSource.objects.get(pk=id)
......@@ -479,6 +479,7 @@ class MustahikGraphQLTestCase(GraphQLTestCase):
self.assertEqual(content['data']['q3']['id'], str(institusi_detail.data_source.pk))
self.assertEqual(content['data']['q3']['detail']['__typename'], 'DataSourceInstitusiType')
def test_data_source_mutation_can_add_new_data_source(self):
existing_data_source_ammount = DataSource.objects.count()
response = self.query(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment