database: don't create a date object in query() unless it's necessary

`query()` calls `datetime.datetime.fromtimestamp` regardless of whether a
date query is being done. Guard this with an if statement to avoid the
unnecessary work.
This commit is contained in:
Todd Gamblin 2021-02-11 00:52:37 -08:00 committed by Massimiliano Culpo
parent c81ca37dfc
commit 3b3314802e

View File

@ -1454,11 +1454,12 @@ def _query(
rec.spec.name) != known:
continue
inst_date = datetime.datetime.fromtimestamp(
rec.installation_time
)
if not (start_date < inst_date < end_date):
continue
if start_date or end_date:
inst_date = datetime.datetime.fromtimestamp(
rec.installation_time
)
if not (start_date < inst_date < end_date):
continue
if (query_spec is any or
rec.spec.satisfies(query_spec, strict=True)):