Skip to content

Commit

Permalink
Merge pull request #129 from VallariAg/filter-by-user
Browse files Browse the repository at this point in the history
Add controller to filter runs by user
  • Loading branch information
zmc authored Sep 19, 2024
2 parents 108240f + 51a39b5 commit 3074849
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions paddles/controllers/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ def get_lookup_controller(self):
return SuiteController


class UsersController(RunFilterIndexController):
def get_subquery(self, query):
return query.values(Run.user)

def get_lookup_controller(self):
return UserController


class StatusesController(RunFilterIndexController):
def get_subquery(self, query):
return query.values(Run.status)
Expand Down Expand Up @@ -187,6 +195,8 @@ def get_lookup_controller(self, field):
return StatusesController()
if field == 'suite':
return SuitesController()
if field == 'user':
return UsersController()


class DateController(RunFilterController):
Expand All @@ -213,6 +223,8 @@ def get_lookup_controller(self, field):
return Sha1sController()
if field == 'suite':
return SuitesController()
if field == 'user':
return UsersController()


class MachineTypeController(RunFilterController):
Expand All @@ -230,6 +242,8 @@ def get_lookup_controller(self, field):
return Sha1sController()
if field == 'suite':
return SuitesController()
if field == 'user':
return UsersController()


class StatusController(RunFilterController):
Expand All @@ -247,6 +261,8 @@ def get_lookup_controller(self, field):
return Sha1sController()
if field == 'suite':
return SuitesController()
if field == 'user':
return UsersController()


class SuiteController(RunFilterController):
Expand All @@ -264,6 +280,27 @@ def get_lookup_controller(self, field):
return Sha1sController()
if field == 'status':
return StatusesController()
if field == 'user':
return UsersController()


class UserController(RunFilterController):
def get_subquery(self, query):
return query.filter(Run.user == self.value)

def get_lookup_controller(self, field):
if field == 'branch':
return BranchesController()
if field == 'date':
return DatesController()
if field == 'machine_type':
return MachineTypesController()
if field == 'sha1':
return Sha1sController()
if field == 'status':
return StatusesController()
if field == 'suite':
return SuitesController()


class DateRangeController(object):
Expand Down Expand Up @@ -316,6 +353,8 @@ def get_lookup_controller(self, field):
return StatusesController()
if field == 'suite':
return SuitesController()
if field == 'user':
return UsersController()



Expand Down Expand Up @@ -361,6 +400,8 @@ def _create_run(cls, name):

sha1 = Sha1sController()

user = UsersController()

@expose('json')
def _lookup(self, name, *remainder):
return RunController(name), remainder

0 comments on commit 3074849

Please sign in to comment.