Skip to content

Commit

Permalink
fix: TreeDetails endpoint filter should use where in
Browse files Browse the repository at this point in the history
  • Loading branch information
lfjnascimento committed Jul 19, 2024
1 parent 96f6aed commit 474f465
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions backend/kernelCI_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,17 @@ def get(self, request, commit_hash):
).where(git_commit_hash__eq=commit_hash)

for k in request.GET.keys():
if k.startswith('filter_'):
field = k[7:]
if field in build_fields or field in checkout_fields:
filter_list = request.GET.getlist(k)
query.where({field: filter_list})
if not k.startswith('filter_'):
continue
field = k[7:]
table = None
if field in build_fields:
table = 'builds'
if field in checkout_fields:
table = 'checkouts'
if table:
filter_list = request.GET.getlist(k)
query.where(**{f'{table}.{field}__in': filter_list})

records = query.select()
for r in records:
Expand Down

0 comments on commit 474f465

Please sign in to comment.