Merge branch 'master' into master

This commit is contained in:
Curtis 2018-05-25 11:09:23 -07:00 committed by GitHub
commit ae26e44cc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,7 @@ services:
command: make test command: make test
environment: environment:
SQLALCHEMY_DATABASE_URI: postgresql://lemur:lemur@postgres:5432/lemur SQLALCHEMY_DATABASE_URI: postgresql://lemur:lemur@postgres:5432/lemur
VIRTUAL_ENV: 'true'
postgres: postgres:
image: postgres:9.4 image: postgres:9.4

View File

@ -268,6 +268,11 @@ def clone(model):
def get_count(q): def get_count(q):
"""
Count the number of rows in a table. More efficient than count(*)
:param q:
:return:
"""
count_q = q.statement.with_only_columns([func.count()]).order_by(None) count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar() count = q.session.execute(count_q).scalar()
return count return count