-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_widget.py
More file actions
26 lines (21 loc) · 1001 Bytes
/
debug_widget.py
File metadata and controls
26 lines (21 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from app import app, db
from models import Master, Transaction, User
from datetime import date, datetime
with app.app_context():
today = date.today()
today_start = datetime.combine(today, datetime.min.time())
today_end = datetime.combine(today, datetime.max.time())
print(f"Today: {today}")
print(f"Range: {today_start} to {today_end}")
top_masters_data = db.session.query(
Master.name, db.func.sum(Transaction.real_amount + Transaction.shelf_amount).label('total')
).join(Transaction).filter(
Transaction.date.between(today_start, today_end)
).group_by(Master.name).order_by(db.desc('total')).limit(3).all()
print(f"Top Masters Query Result: {top_masters_data}")
# Check current user 'admin'
admin = User.query.filter_by(username='admin').first()
if admin:
print(f"User 'admin': Role={admin.role}, is_owner={admin.is_owner}, is_analyst={admin.is_analyst}")
else:
print("User 'admin' not found")