Skip to content

Commit fec030d

Browse files
authored
Merge branch 'enrollment-filter' of 'https://github.com/evamillan/grimoirelab-sortinghat'
Merges #789 Closes #789
2 parents 6fdc5fd + ced71f0 commit fec030d

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Enrollment filter on organizations view
3+
category: fixed
4+
author: Eva Millan <[email protected]>
5+
issue: null
6+
notes: >
7+
Filtering individuals by their affiliation to an organization
8+
also returned results of organizations that contained that name.
9+
The filter now only returns organizations that match the exact
10+
name.

sortinghat/core/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ def resolve_individuals(self, info, filters=None,
15941594
.values_list('individual__mk')))
15951595
if filters and 'enrollment' in filters:
15961596
query = query.filter(mk__in=Subquery(Enrollment.objects
1597-
.filter(group__name__icontains=filters['enrollment'])
1597+
.filter(group__name=filters['enrollment'])
15981598
.values_list('individual__mk')))
15991599
if 'enrollment_parent_org' in filters:
16001600
query = query.filter(mk__in=Subquery(Enrollment.objects

tests/test_schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3659,12 +3659,12 @@ def test_filter_enrollment(self):
36593659
enrollment = indv['enrollments'][0]
36603660
self.assertEqual(enrollment['group']['name'], 'Bitergia')
36613661

3662-
# Test partial organization name match
3662+
# Test no results for partial organization name match
36633663
executed = client.execute(SH_INDIVIDUALS_ENROLLMENT_FILTER % 'bit',
36643664
context_value=self.context_value)
36653665

36663666
individuals = executed['data']['individuals']['entities']
3667-
self.assertEqual(len(individuals), 2)
3667+
self.assertEqual(len(individuals), 0)
36683668

36693669
# Test organization name with spaces
36703670
executed = client.execute(SH_INDIVIDUALS_ENROLLMENT_FILTER % 'bit company',
@@ -3709,12 +3709,12 @@ def test_filter_team_enrollment(self):
37093709
self.assertEqual(enrollment['group']['name'], 'Team 1')
37103710
self.assertEqual(enrollment['group']['type'], 'team')
37113711

3712-
# Test partial team name match
3712+
# Test no results for partial team name match
37133713
executed = client.execute(SH_INDIVIDUALS_ENROLLMENT_FILTER % 'tea',
37143714
context_value=self.context_value)
37153715

37163716
individuals = executed['data']['individuals']['entities']
3717-
self.assertEqual(len(individuals), 2)
3717+
self.assertEqual(len(individuals), 0)
37183718

37193719
# Test no results for enrollment
37203720
executed = client.execute(SH_INDIVIDUALS_ENROLLMENT_FILTER % 'Organization',

0 commit comments

Comments
 (0)