Skip to content

Commit

Permalink
Change filtered row count function
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Aug 1, 2019
1 parent b246805 commit e6f53da
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,6 @@ def get_rows_by_filter(table, filters):
return list(map(lambda x: x.to_dict(), results))


def get_filtered_row_count(table, filters):
"""
returns the count of the rows that match a given filter in a given table
:param table: the table to be checked
:param filters: the filters to be applied to the query
:return: int: the count of the rows
"""
log.info(f" Getting filtered row count for {table.__tablename__}")
return len(get_rows_by_filter(table, filters))


def get_first_filtered_row(table, filters):
Expand All @@ -297,6 +288,23 @@ def get_first_filtered_row(table, filters):
return get_rows_by_filter(table, filters)[0]


def get_filtered_row_count(table, filters):
"""
returns the count of the rows that match a given filter in a given table
:param table: the table to be checked
:param filters: the filters to be applied to the query
:return: int: the count of the rows
"""
log.info(f" getting count for {table.__tablename__}")
count_query = CountQuery(table)
for filter in filters:
if len(filter) == 0:
pass
else:
QueryFilterFactory.get_query_filter(filter).apply_filter(count_query)
return count_query.get_count()


def patch_entities(table, json_list):
"""
Update one or more rows in the given table, from the given list containing json. Each entity must contain its ID
Expand Down

0 comments on commit e6f53da

Please sign in to comment.