Skip to content

Commit

Permalink
#30: Add precedence to filters
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Aug 10, 2019
1 parent bac726e commit 31fbe83
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def apply_filter(self, query):


class WhereFilter(QueryFilter):
precedence = 0

def __init__(self, field, value):
self.field = field
self.value = value
Expand All @@ -132,6 +134,8 @@ def apply_filter(self, query):


class OrderFilter(QueryFilter):
precedence = 1

def __init__(self, field, direction):
self.field = field
self.direction = direction
Expand All @@ -148,6 +152,8 @@ def apply_filter(self, query):


class SkipFilter(QueryFilter):
precedence = 2

def __init__(self, skip_value):
self.skip_value = skip_value

Expand All @@ -156,6 +162,8 @@ def apply_filter(self, query):


class LimitFilter(QueryFilter):
precedence = 3

def __init__(self, limit_value):
self.limit_value = limit_value

Expand All @@ -165,6 +173,8 @@ def apply_filter(self, query):


class IncludeFilter(QueryFilter):
precedence = 4

def __init__(self, included_filters):
self.included_filters = included_filters

Expand Down

0 comments on commit 31fbe83

Please sign in to comment.