-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,7 @@ def __set_take_for(self, member, amount, recorder): | |
""", dict(member=member.username, team=self.username, amount=amount, | ||
recorder=recorder.username)) | ||
|
||
def get_takes(self, for_payday=False): | ||
def get_takes(self, for_payday=False, cursor=None): | ||
"""Return a list of member takes for a team. | ||
This is implemented parallel to Participant.get_tips_and_total. See | ||
|
@@ -194,14 +194,15 @@ def get_takes(self, for_payday=False): | |
""" | ||
|
||
return self.db.all(TAKES, args, back_as=dict) | ||
records = (cursor or self.db).all(TAKES, args) | ||
return [r._asdict() for r in records] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Changaco
Author
Contributor
|
||
|
||
def get_team_take(self): | ||
def get_team_take(self, cursor=None): | ||
"""Return a single take for a team, the team itself's take. | ||
""" | ||
assert self.IS_PLURAL | ||
TAKE = "SELECT sum(amount) FROM current_takes WHERE team=%s" | ||
total_take = self.db.one(TAKE, (self.username,), default=0) | ||
total_take = (cursor or self.db).one(TAKE, (self.username,), default=0) | ||
team_take = max(self.receiving - total_take, 0) | ||
membership = { "ctime": None | ||
, "mtime": None | ||
|
@@ -210,12 +211,12 @@ def get_team_take(self): | |
} | ||
return membership | ||
|
||
def compute_actual_takes(self): | ||
def compute_actual_takes(self, cursor=None): | ||
"""Get the takes, compute the actual amounts, and return an OrderedDict. | ||
""" | ||
actual_takes = OrderedDict() | ||
nominal_takes = self.get_takes() | ||
nominal_takes.append(self.get_team_take()) | ||
nominal_takes = self.get_takes(cursor=cursor) | ||
nominal_takes.append(self.get_team_take(cursor=cursor)) | ||
budget = balance = self.receiving | ||
for take in nominal_takes: | ||
nominal_amount = take['nominal_amount'] = take.pop('amount') | ||
|
1 comment
on commit 0e1aa9e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit lgtm.
Interesting. Where is the
_asdict
API coming from? Is that a psycopg2 thing?