mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 20:51:49 +02:00
Optim balances computation
Query only bills associated with project first
This commit is contained in:
parent
fb69e8aa89
commit
6c31f89db4
1 changed files with 3 additions and 2 deletions
|
@ -35,10 +35,11 @@ class Project(db.Model):
|
||||||
for time in (1, 2, 3))
|
for time in (1, 2, 3))
|
||||||
|
|
||||||
# for each person
|
# for each person
|
||||||
|
bills_in_project = self.get_bills()
|
||||||
for person in self.members:
|
for person in self.members:
|
||||||
# get the list of bills he has to pay
|
# get the list of bills he has to pay
|
||||||
bills = Bill.query.filter(Bill.owers.contains(person))
|
bills = bills_in_project.filter(Bill.owers.contains(person)).all()
|
||||||
for bill in bills.all():
|
for bill in bills:
|
||||||
if person != bill.payer:
|
if person != bill.payer:
|
||||||
share = bill.pay_each() * person.weight
|
share = bill.pay_each() * person.weight
|
||||||
should_pay[person] += share
|
should_pay[person] += share
|
||||||
|
|
Loading…
Reference in a new issue