updated forms

This commit is contained in:
2024-10-24 11:51:14 -04:00
parent 5649294be0
commit b3f0e85574
10 changed files with 340 additions and 208 deletions

View File

@@ -147,6 +147,7 @@ def get_user_stats(user_id):
.query(Stats_Customer) \
.filter(Stats_Customer.customer_id == user_id) \
.first()
user_schema = Stats_Customer_schema(many=False)
return jsonify(user_schema.dump(get_user))
@@ -190,3 +191,27 @@ def total_gallons_delivered_this_week():
'total': total_gallons,
}), 200
@stats.route("/gallons/check/total/<int:user_id>", methods=["GET"])
def calculate_gallons_user(user_id):
# Get today's date
total_gallons = 0
# Get the date of the Monday for today
get_total = (db.session
.query(Delivery_Delivery)
.filter(Delivery_Delivery.customer_id == user_id)
.all())
get_user = db.session \
.query(Stats_Customer) \
.filter(Stats_Customer.customer_id == user_id) \
.first()
for f in get_total:
total_gallons = total_gallons + f.gallons_delivered
get_user.oil_total_gallons = total_gallons
db.session.add(get_user)
db.session.commit()
return jsonify({"ok": True,
}), 200