Skip to content

Commit

Permalink
feat: add origin filter to tree endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lfjnascimento committed Aug 15, 2024
1 parent 01833fd commit e0b3343
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/kernelCI_app/views/treeView.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
from kernelCI_app.utils import getQueryTimeInterval


DEFAULT_ORIGIN = '0dayci'


class TreeView(View):
def get(self, request):
origin = request.GET.get('origin', DEFAULT_ORIGIN)

def get(self, _):
checkouts = Checkouts.objects.raw(
"""
WITH
Expand All @@ -19,7 +23,7 @@ def get(self, _):
start_time
FROM
checkouts
WHERE start_time >= TO_TIMESTAMP(%s)
WHERE origin = %s AND start_time >= TO_TIMESTAMP(%s)
) AS selection
ORDER BY
start_time DESC
Expand Down Expand Up @@ -56,7 +60,7 @@ def get(self, _):
GROUP BY
checkouts.git_commit_hash, checkouts.patchset_hash
;
""", [getQueryTimeInterval().timestamp()]
""", [origin, getQueryTimeInterval().timestamp()]
)

serializer = TreeSerializer(checkouts, many=True)
Expand Down

0 comments on commit e0b3343

Please sign in to comment.