bitvend/models: fix 0 transaction users
parent
1895d785c2
commit
404a4a5903
|
@ -65,13 +65,13 @@ class User(db.Model):
|
|||
return "<User {0.uid} {0.balance}>".format(self)
|
||||
|
||||
balance = column_property(
|
||||
select([func.sum(Transaction.amount)])
|
||||
select([func.coalesce(func.sum(Transaction.amount), 0)])
|
||||
.where(Transaction.uid == uid)
|
||||
.correlate_except(Transaction)
|
||||
)
|
||||
|
||||
purchase_count = column_property(
|
||||
select([func.count(Transaction.amount)])
|
||||
select([func.coalesce(func.count(Transaction.amount), 0)])
|
||||
.where(and_(Transaction.uid == uid, Transaction.type == "purchase"))
|
||||
.correlate_except(Transaction)
|
||||
)
|
||||
|
@ -84,7 +84,7 @@ class User(db.Model):
|
|||
)
|
||||
|
||||
purchase_amount = column_property(
|
||||
select([-func.sum(Transaction.amount)])
|
||||
select([func.coalesce(-func.sum(Transaction.amount), 0)])
|
||||
.where(and_(Transaction.uid == uid, Transaction.type == "purchase"))
|
||||
.correlate_except(Transaction)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue