|
14 | 14 | @jwt_required() |
15 | 15 | def list_bills(): |
16 | 16 | uid = int(get_jwt_identity()) |
17 | | - items = db.session.query(Bill).filter_by(user_id=uid, active=True).order_by(Bill.next_due_date).all() |
| 17 | + items = ( |
| 18 | + db.session.query(Bill) |
| 19 | + .filter_by(user_id=uid, active=True) |
| 20 | + .order_by(Bill.next_due_date) |
| 21 | + .all() |
| 22 | + ) |
18 | 23 | logger.info("List bills user=%s count=%s", uid, len(items)) |
19 | | - return jsonify([ |
20 | | - { |
21 | | - "id": b.id, |
22 | | - "name": b.name, |
23 | | - "amount": float(b.amount), |
24 | | - "currency": b.currency, |
25 | | - "next_due_date": b.next_due_date.isoformat(), |
26 | | - "cadence": b.cadence.value, |
27 | | - "channel_whatsapp": b.channel_whatsapp, |
28 | | - "channel_email": b.channel_email, |
29 | | - } |
30 | | - for b in items |
31 | | - ]) |
| 24 | + return jsonify( |
| 25 | + [ |
| 26 | + { |
| 27 | + "id": b.id, |
| 28 | + "name": b.name, |
| 29 | + "amount": float(b.amount), |
| 30 | + "currency": b.currency, |
| 31 | + "next_due_date": b.next_due_date.isoformat(), |
| 32 | + "cadence": b.cadence.value, |
| 33 | + "channel_whatsapp": b.channel_whatsapp, |
| 34 | + "channel_email": b.channel_email, |
| 35 | + } |
| 36 | + for b in items |
| 37 | + ] |
| 38 | + ) |
32 | 39 |
|
33 | 40 |
|
34 | 41 | @bp.post("") |
@@ -71,5 +78,7 @@ def mark_paid(bill_id: int): |
71 | 78 | b.active = False |
72 | 79 | db.session.commit() |
73 | 80 | cache_delete_patterns([f"user:{uid}:upcoming_bills*"]) |
74 | | - logger.info("Marked bill paid id=%s user=%s next_due_date=%s", b.id, uid, b.next_due_date) |
| 81 | + logger.info( |
| 82 | + "Marked bill paid id=%s user=%s next_due_date=%s", b.id, uid, b.next_due_date |
| 83 | + ) |
75 | 84 | return jsonify(message="updated") |
0 commit comments