first commit
This commit is contained in:
7
app/stats/__init__.py
Normal file
7
app/stats/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# coding=utf-8
|
||||
|
||||
from flask import Blueprint
|
||||
|
||||
stats = Blueprint('stats', __name__)
|
||||
|
||||
from . import views
|
||||
31
app/stats/views.py
Normal file
31
app/stats/views.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from flask import jsonify
|
||||
from sqlalchemy import func
|
||||
from datetime import date
|
||||
from app.stats import stats
|
||||
from app import db
|
||||
from app.classes.delivery import Delivery_Delivery
|
||||
from app.classes.service import Service_Call
|
||||
|
||||
|
||||
@stats.route("/delivery/count/today", methods=["GET"])
|
||||
def get_delivery_today():
|
||||
today_deliveries = (db.session
|
||||
.query(Delivery_Delivery)
|
||||
.order_by(func.date(Delivery_Delivery.expected_delivery_date) == date.today())
|
||||
.count())
|
||||
|
||||
return jsonify({"ok": True,
|
||||
'data': today_deliveries,
|
||||
}), 200
|
||||
|
||||
|
||||
@stats.route("/service/count/today", methods=["GET"])
|
||||
def get_service_today():
|
||||
today_calls = (db.session
|
||||
.query(Service_Call)
|
||||
.order_by(func.date(Service_Call.scheduled_date) == date.today())
|
||||
.count())
|
||||
|
||||
return jsonify({"ok": True,
|
||||
'data': today_calls,
|
||||
}), 200
|
||||
Reference in New Issue
Block a user