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

History page: show tipper if it's a team you're a member of #2173

Merged
merged 3 commits into from
May 1, 2014

Conversation

seanlinsley
Copy link
Contributor

Once this is complete, it'll resolve #1126

This is 100% untested because I have no idea how to get a fake payday working with fake money.


UPDATE transfers SET as_team_member = true
FROM participants WHERE participants.username = transfers.tipper
AND participants.number = 'plural';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this needs to confirm that the recipient is a team member. Is there a way to deal with the edge case where the recipient received money from the plural account both as a direct tip and as a team member (perhaps at different points in time)?

@chadwhitacre
Copy link
Contributor

This is 100% untested because I have no idea how to get a fake payday working with fake money.

We do have payday tests in tests/py/test_billing_payday.py. That's the place to start with testing this.

@seanlinsley
Copy link
Contributor Author

I don't get what you mean; this has nothing to do with actually running the payday.

@chadwhitacre
Copy link
Contributor

@seanlinsley Doesn't it? The main changes to code here are to billing/payday.py, and above you say, "I have no idea how to get a fake payday working."

@Changaco
Copy link
Contributor

I've reviewed this PR, rebased it on master and rewrote the UPDATE query in branch.sql. It should now correctly set as_team_member to true, except if the user was simultaneously receiving a take and a tip with the same amounts from the same team, which I think is quite unlikely.

This PR doesn't make any breaking change, so if we got something wrong we won't have broken anything. Unless there are objections I'll merge this tomorrow.

Changaco added a commit that referenced this pull request May 1, 2014
History page: show tipper if it's a team you're a member of
@Changaco Changaco merged commit efb844d into master May 1, 2014
@Changaco Changaco deleted the 1126-show-teams-on-history-page branch May 1, 2014 07:54
@Changaco
Copy link
Contributor

Changaco commented May 1, 2014

branch.sql completed without problem. 3548 transfers were marked as_team_member by the UPDATE query, out of 239570 total transfers.

@Changaco
Copy link
Contributor

Changaco commented May 1, 2014

It appears that I missed something, only takes before week 85 are being shown as coming from the Gittip team on my history page.

@Changaco
Copy link
Contributor

Changaco commented May 1, 2014

OK, I think I got it. Here are the queries I used:

UPDATE transfers
   SET as_team_member = true
 WHERE amount <= (
           SELECT amount
             FROM takes t
            WHERE t.team = transfers.tipper
              AND t.member = transfers.tippee
              AND t.mtime < transfers.timestamp
         ORDER BY t.mtime DESC
            LIMIT 1
       );

UPDATE transfers
   SET as_team_member = false
 WHERE as_team_member = true
   AND amount = (
           SELECT amount
             FROM tips t
            WHERE t.tipper = transfers.tipper
              AND t.tippee = transfers.tippee
              AND t.mtime < transfers.timestamp
         ORDER BY t.mtime DESC
            LIMIT 1
       );

Result:

UPDATE 5187
UPDATE 3

clone1018 added a commit that referenced this pull request May 1, 2014
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.

receipts as member of team shouldn't be anon
4 participants