aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--quarg/main.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/quarg/main.py b/quarg/main.py
index 69c99de..ce72310 100644
--- a/quarg/main.py
+++ b/quarg/main.py
@@ -96,9 +96,7 @@ def collect_predicates(args):
else:
yield fun(value)
-def run_query(session, predicates, args):
- start = timer()
-
+def prepare_query(session, predicates, args):
query = session.query(Backlog).join(Sender).join(Buffer).join(Network).join(QuasselUser)
for predicate in predicates:
@@ -113,11 +111,13 @@ def run_query(session, predicates, args):
if args.limit:
query = query.limit(args.limit)
- rows = query.all()
+ return query
+def time_query(query):
+ start = timer()
+ rows = query.all()
end = timer()
-
- return (rows, end - start)
+ return rows, end - start
def main():
config = get_config()
@@ -136,7 +136,8 @@ def main():
if not predicates:
errx('Nothing to match.')
- rows, time = run_query(session, predicates, args)
+ query = prepare_query(session, predicates, args)
+ rows, time = time_query(query)
for row in rows:
print(format_from(row))