Skip to content

Commit 4d7976a

Browse files
committed
Move ancestor-finding code for Organizations to that model's module
1 parent 9979adb commit 4d7976a

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

pupa/utils/fulltext.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,10 @@ def bill_to_elasticsearch(bill):
9292
for other_title in bill.other_titles.all():
9393
es_bill['titles'].append(other_title.title)
9494

95-
# Recursively retrieve all organizations that the bill is related to
96-
es_bill['organizations'] = []
9795
organization = bill.from_organization
98-
while True:
99-
try:
100-
es_bill['organizations'].append(organization.name)
101-
except AttributeError:
102-
break
103-
organization = organization.parent
96+
es_bill['organizations'] = [organization.name, ]
97+
for ancestor in organization.get_parents():
98+
es_bill['organizations'].append(ancestor.name)
10499

105100
es_bill['sponsors'] = []
106101
for sponsor in bill.sponsorships.all().filter(bill=bill):

0 commit comments

Comments
 (0)