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

rationalize cached values #3721

Merged
merged 24 commits into from
Aug 30, 2015
Merged

rationalize cached values #3721

merged 24 commits into from
Aug 30, 2015

Conversation

chadwhitacre
Copy link
Contributor

Follow-on from #3599.

@chadwhitacre chadwhitacre added this to the Pivot milestone Aug 29, 2015
@chadwhitacre
Copy link
Contributor Author

Picking up from #3599 (comment), here is where we are and where we're going:

                sum           count        sharing bit
                ----------------------------------------------
current  ~user  giving        —            anonymous_giving
                receiving     npatrons     anonymous_receiving
                taking        —            anonymous_receiving

         Team   receiving     nsupporters  —
                payroll       nmembers     —       

target   ~user  giving        nrecipients  anonymous_giving
                taking        nteams       -

         Team   receiving     ngivers      —
                distributing  nmembers     —

The one change here from the original comment is that I've dropped anonymous_taking. There is no anonymous taking in Gratipay 2.0. Payroll is public, as are the numbers relative to Teams.

@chadwhitacre
Copy link
Contributor Author

Here's the diff:

  • remove participants.npatrons
  • remove participants.receiving
  • remove participants.anonymous_receiving
  • add participants.nrecipients went with ngiving_to (see message on 7306177)
  • add participants.nteams went with ntaking_from
  • include owner draws in participants.taking
  • rename teams.nsupporters to teams.ngivers
  • rename teams.payroll to teams.distributing

For each:

  • ALTER TABLE
  • add/modify code and tests
  • UI

@chadwhitacre
Copy link
Contributor Author

I think as part of this that we should move away from estimating dollar amounts (receiving, taking) based on the future, and instead base it on the past. Why? The past is more predictable than the future. :-)

This may well obviate is_funded (though does payday depend on that?).

I think we should cache last week's actual amount, and an average of the past four weeks. These two numbers will provide a fine answer to the question, "How much will my Team receive this week?"

@chadwhitacre
Copy link
Contributor Author

Basing receiving on the past instead of the future also lets us avoid the gymnastics we're currently doing to simulate payday every time someone changes their credit card or whatever. It's going to be simpler.

@chadwhitacre
Copy link
Contributor Author

I guess we can just update all of the numbers once at the end of each payday, rather than having to update them constantly throughout the week in response to various events (payment instruction changes, route changes).

@chadwhitacre
Copy link
Contributor Author

The downside is that one won't be able to watch drastic movement that happens inside a week. Especially early on, we paid a lot of attention to intra-week movement. I think that Gratipay has matured, and we are ready to lengthen our attention span. Gratipay is intended to inculcate the long view. You'll get to see this week's amazing growth ... on Thursday.

@chadwhitacre
Copy link
Contributor Author

How about taking and distributing? Those depend somewhat on the income that a Team receives, but are largely in the control of Team members. Those numbers aren't as squidgy as receiving. Should we refer taking and distributing to the future instead of the past? Should we base those on Team members' payroll_instructions rather than on past payments?

@rohitpaulk
Copy link
Contributor

though does payday depend on that?

No, it doesn't. :)

I don't think going back on cached values is a good idea though... When I tip someone, I expect their receiving amount to increase. Similarly if I was a team, I'd like to know an estimate of how much I'm going to receive. This stuff is very useful, @whit537.

@chadwhitacre
Copy link
Contributor Author

When I tip someone, I expect their receiving number to increase.

Hmmm ... that's hard to argue with. :)

@chadwhitacre
Copy link
Contributor Author

I'm working through the tests here and realizing that we have a lot of skips and a lot of JSON endpoint tests that are obsoleted by 1.0 and the move away from tips. I'm finding that I want to cut out all that cruft before proceeding here.

@chadwhitacre chadwhitacre force-pushed the rationalize-cached-values branch from cbff1dd to c5c3732 Compare August 29, 2015 11:13
@chadwhitacre
Copy link
Contributor Author

Starting over with an ordered approach: removing anonymous_receiving.

@chadwhitacre
Copy link
Contributor Author

I.e., taking each diff item in turn, one at a time.

Leaves three:

 - charts.json
 - number.json
 - receiving/
We no longer expose number in the UI, so number.json is not useful.
We're gettin' pretty thin here ...
@chadwhitacre chadwhitacre force-pushed the rationalize-cached-values branch 2 times, most recently from 2b916bb to 9579e2c Compare August 29, 2015 21:41
@chadwhitacre chadwhitacre force-pushed the rationalize-cached-values branch from 2b916bb to 9f778e2 Compare August 29, 2015 21:47
@chadwhitacre
Copy link
Contributor Author

The remaining test failures get us into @book's questions on #3666.

@chadwhitacre
Copy link
Contributor Author

To keep this PR under control I think we should have the cached values reflect whatever the current behavior of payday is. If we want to change the behavior below #3666 then that'll be a separate PR.

@chadwhitacre
Copy link
Contributor Author

Is the javascript dynamically updating amounts properly?

@chadwhitacre
Copy link
Contributor Author

No! :-)

@chadwhitacre
Copy link
Contributor Author

I'm also checking the pricing page and the global cta ...

@chadwhitacre
Copy link
Contributor Author

Okay! Waiting for Travis ...

chadwhitacre added a commit that referenced this pull request Aug 30, 2015
@chadwhitacre chadwhitacre merged commit e904447 into master Aug 30, 2015
@chadwhitacre chadwhitacre deleted the rationalize-cached-values branch August 30, 2015 09:06
@chadwhitacre
Copy link
Contributor Author

😩

@chadwhitacre
Copy link
Contributor Author

Code and schema deployed, running the cache refresh script ...

@chadwhitacre
Copy link
Contributor Author

Done! :-)

screen shot 2015-08-30 at 5 12 01 am

@mattbk
Copy link
Contributor

mattbk commented Aug 30, 2015

!m @whit537!

@chadwhitacre
Copy link
Contributor Author

Thanks. :-)

@mattbk
Copy link
Contributor

mattbk commented Sep 4, 2015

I had a question about the receiving amount, but this explains it:

I think we should cache last week's actual amount, and an average of the past four weeks. These two numbers will provide a fine answer to the question, "How much will my Team receive this week?"

My one supporter is no longer supporting, according to History.

@chadwhitacre
Copy link
Contributor Author

Here's what we ended up with ftr:

       sum           count             sharing bit
       ------------------------------------------------
~user  giving        ngiving_to        anonymous_giving
       taking        ntaking_from      —

Team   receiving     nreceiving_from   —
       distributing  ndistributing_to  —

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants