From f8ad9763fdb83b78cb67cc2404cf5da4f98c58f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Gru=CC=88ndger?= Date: Sun, 22 Nov 2020 12:09:02 +0100 Subject: [PATCH] Fixed db queries ('is True' != '== db.true()') --- app/main/routes.py | 8 ++++---- app/templates/airport_detail.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/main/routes.py b/app/main/routes.py index 67ea3d0..54d32a2 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -49,8 +49,8 @@ def index(): senders_today = db.session.query(db.func.count(Sender.id)).filter(Sender.lastseen >= today_beginning).one()[0] receivers_today = db.session.query(db.func.count(Receiver.id)).filter(Receiver.lastseen >= today_beginning).one()[0] - takeoffs_today = db.session.query(db.func.count(TakeoffLanding.id)).filter(db.and_(TakeoffLanding.timestamp >= today_beginning, TakeoffLanding.is_takeoff is True)).one()[0] - landings_today = db.session.query(db.func.count(TakeoffLanding.id)).filter(db.and_(TakeoffLanding.timestamp >= today_beginning, TakeoffLanding.is_takeoff is False)).one()[0] + takeoffs_today = db.session.query(db.func.count(TakeoffLanding.id)).filter(db.and_(TakeoffLanding.timestamp >= today_beginning, TakeoffLanding.is_takeoff == db.true())).one()[0] + landings_today = db.session.query(db.func.count(TakeoffLanding.id)).filter(db.and_(TakeoffLanding.timestamp >= today_beginning, TakeoffLanding.is_takeoff == db.false())).one()[0] sender_positions_today = db.session.query(db.func.sum(ReceiverStatistic.messages_count)).filter(ReceiverStatistic.date == date.today()).one()[0] sender_positions_total = db.session.query(db.func.sum(ReceiverStatistic.messages_count)).one()[0] @@ -216,7 +216,7 @@ def download_flight(): @bp.route("/sender_ranking.html") def sender_ranking(): sender_statistics = db.session.query(SenderStatistic) \ - .filter(db.and_(SenderStatistic.date == date.today(), SenderStatistic.is_trustworthy is True)) \ + .filter(db.and_(SenderStatistic.date == date.today(), SenderStatistic.is_trustworthy == db.true())) \ .order_by(SenderStatistic.max_distance.desc()) \ .all() @@ -229,7 +229,7 @@ def sender_ranking(): @bp.route("/receiver_ranking.html") def receiver_ranking(): receiver_statistics = db.session.query(ReceiverStatistic) \ - .filter(db.and_(ReceiverStatistic.date == date.today(), ReceiverStatistic.is_trustworthy is True)) \ + .filter(db.and_(ReceiverStatistic.date == date.today(), ReceiverStatistic.is_trustworthy == db.true())) \ .order_by(ReceiverStatistic.max_distance.desc()) \ .all() diff --git a/app/templates/airport_detail.html b/app/templates/airport_detail.html index 8a75800..71377f3 100644 --- a/app/templates/airport_detail.html +++ b/app/templates/airport_detail.html @@ -48,7 +48,7 @@ {% for sender in senders %} {{ sender|to_html_link|safe }} - {% if sender.takeoff_landings %}{% set last_action = sender.takeoff_landings|last %}{% if last_action.is_takeoff == True %}↗{% else %}↘{% endif %} @ {{ last_action.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}{% endif %} + {% if sender.takeoff_landings %}{% set last_action = sender.takeoff_landings|last %}{% if last_action.is_takeoff == db.true() %}↗{% else %}↘{% endif %} @ {{ last_action.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}{% endif %} {% if sender.hardware_version is not none %}{{ sender.hardware_version }}{% else %}-{% endif %} {% if sender.software_version is not none %}{{ sender.software_version }}{% else %}-{% endif %}