Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

plumb takes #4023

Closed
wants to merge 4 commits into from
Closed

plumb takes #4023

wants to merge 4 commits into from

Conversation

chadwhitacre
Copy link
Contributor

@chadwhitacre chadwhitacre commented May 11, 2016

#3994

#4070#4024

Punchlist

  • Takes determinesTakes determine
  • There is no Membership mixin yet (docstring).
  • require working payout route
  • add recorder to both methods
  • upgrade ntakes to bigint
  • prevent the owner from claiming takes (they get baseline and unclaimed) plumb takes #4023 (comment)
  • update participants.taking
  • move cacherinoes into Postgres (triggers) nevermind → rationalize computed values #4064
  • prune the old _mixin_teams.py file
  • handle takes during take_over
  • remake against master once use source order for docs #4070 lands

@chadwhitacre
Copy link
Contributor Author

prevent the owner from claiming takes (they get baseline and unclaimed)

Actually, let's leave this up to the teams to decide, ya?

@chadwhitacre chadwhitacre force-pushed the takes-plumbing branch 2 times, most recently from 94ab07e to 74bbcb6 Compare May 12, 2016 12:20
@chadwhitacre
Copy link
Contributor Author

I want to handle takes during take_over as with identities: hard-failing (we really should already be failing for or otherwise handling the case where one account takes over another that owns one or more teams). The easiest way to handle this will be with a check for other.ntaking_from > 0, so that gets back to the other open item on the punchlist: updating taking and ntaking_from. Since takes are proportional now instead of absolute, changes to one person's takes affect the taking of all other members of the team, plus the owner. Working it through ...

@chadwhitacre
Copy link
Contributor Author

ntaking_from is easy. It's taking that's difficult.

@chadwhitacre
Copy link
Contributor Author

Bringing over here from #3994 (comment) ...

I'm working on writing update_taking as a PL/pgSQL function, because I don't see how to write it in Python without too many database calls.


Looks like we can do it in Python and write back to the database once per team with this mechanism.

Now we're thinking we might try with trigger functions on UPDATE in Postgres.

@chadwhitacre
Copy link
Contributor Author

What needs to change when?

on INSERT into takes
  • for the participant:
    • ntaking_from
    • taking
  • for team mates:
    • n/a
  • for the owner:
    • n/a
  • for the team:
    • ndistributing_to
    • distributing
    • surplus
on UPDATE of teams.receiving
  • for the owner:
    • taking
  • for all members:
    • taking
  • for the team:
    • distributing
    • surplus

@chadwhitacre
Copy link
Contributor Author

Cached values updates in triggers is looking promising: 3fb940a.

@chadwhitacre
Copy link
Contributor Author

chadwhitacre commented May 12, 2016

Following in the illustrious lineage of cached values work #3599, #3721, and #3729 ...

We're now experimenting with calling them "computed" values as opposed to ... what? "Primary" values? "Original" values? "Real" values? "Independent" values? "Assigned" values? "Root" values? "Input" values? "Raw" values? "Observed" values? "Given" values?

Here are the four given values:

i name property of description
1 payment instruction participant amount of money the participant intends to pay a given team, weekly
2 baseline team threshold below which no money will be distributed in any given week
3 takes issued team total number of parts into which money available for weekly distribution will be divided
4 takes claimed participant number of parts of a given team's weekly distribution of money that the participant intends to collect

All the other numbers we care about can be computed from those four:

i name property of function
1 giving participant sum of payment instructions from the given participant
2 ngiving_to participant number of payment instructions from the given participant
3 receiving team sum of payment instructions to the given team
4 nreceiving_from team number of payment instructions to the given team
5 claimed takes team sum of takes claimed from the given team
6 unclaimed takes team takes issued - claimed takes
7 distributing team (claimed takes / takes issued) * (receiving - baseline)
10 ndistributing_to team count of takes claimed for the given team
11 surplus team receiving - baseline - distributing
7 taking participant (sum of (takes claimed / takes issued) * (receiving - baseline) for all memberships) + ((min(receiving, baseline) + surplus) for all ownerships)
8 ntaking_from participant count of (takes claimed by the given participant ∪ ownerships)

given values are bold
computed values are in italics

@mattbk
Copy link
Contributor

mattbk commented May 12, 2016

"Computed values" makes much more sense to me than "cached values" for this sort of thing, FWIW.

"Entered values"?

@chadwhitacre
Copy link
Contributor Author

"Computed values" makes much more sense to me than "cached values" for this sort of thing, FWIW.

Cool. 👍

"Entered values"?

Hmm, maybe ...

@chadwhitacre
Copy link
Contributor Author

We may also want to work "take" into the chart, as the dollar amount a given participant is collecting from a given team.

@chadwhitacre
Copy link
Contributor Author

chadwhitacre commented May 13, 2016

@mattbk Nice! @kaguillera and I were saying we should make a graph. :-)

Could also throw it in http://interactive.blockdiag.com/?

@mattbk
Copy link
Contributor

mattbk commented May 13, 2016

Not sure if blockdiag shows things the same way; the overlapping lines are confusing.

EDIT: different syntax

image

@chadwhitacre
Copy link
Contributor Author

Yeah, that's definitely less clear.

@kaguillera
Copy link
Contributor

!m @mattbk

aandis and others added 3 commits June 25, 2016 22:00
This works around a bug in Sphinx where the print function under Python
2.7 prevents class attributes from showing up in documentation. I want
to be able to document some attributes on the Team class.
This gives us more control. Rarely is alphabetical order the right sort
order.
@chadwhitacre
Copy link
Contributor Author

Rebased, previous head was 3fb940a.

@chadwhitacre
Copy link
Contributor Author

Based on #3994 (comment), for simplicity's sake let's assume for now that a Team will always have enough to cover the amount they're making available for payouts each week. This should be sufficient for #3994, at least.

@chadwhitacre
Copy link
Contributor Author

chadwhitacre commented Jul 1, 2016

Scrapping for parts.

@chadwhitacre chadwhitacre deleted the takes-plumbing branch July 1, 2016 15:08
@chadwhitacre chadwhitacre mentioned this pull request Jul 1, 2016
1 task
chadwhitacre added a commit that referenced this pull request Jul 6, 2016
@chadwhitacre chadwhitacre mentioned this pull request Jul 6, 2016
2 tasks
chadwhitacre added a commit that referenced this pull request Jul 6, 2016
chadwhitacre added a commit that referenced this pull request Jul 6, 2016
@chadwhitacre chadwhitacre mentioned this pull request Jul 7, 2016
15 tasks
chadwhitacre added a commit that referenced this pull request Jul 11, 2016
chadwhitacre added a commit that referenced this pull request Jul 13, 2016
Conflicts:
	sql/branch.sql
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants