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

Project history page #4128

Merged
merged 33 commits into from
Apr 12, 2017
Merged

Project history page #4128

merged 33 commits into from
Apr 12, 2017

Conversation

kaguillera
Copy link
Contributor

This is the stub so far...so it is nowhere ready for review

@mattbk mattbk mentioned this pull request Sep 22, 2016
1 task
@mattbk mattbk added this to the Finish Team Basics milestone Sep 22, 2016
@kaguillera
Copy link
Contributor Author

According the way that fake_data.py works a payment_instruction is made for each participant for each team except for the team owned by that participant.
Thus if there are five teams and five participant each team should have four payment_instructions. Also it should follow that each payday executes these payments (for simplicity all are funded for now) then each payday should produce four payments per team one for each payment_instruction.

Just realized this is limited by ntips.
The question is can I work on the ticket even if the fake_data is messed up. If not how exactly do I fix fake data to give move realistic data and should I?

@kaguillera
Copy link
Contributor Author

Ok I think that I will have to go down the 🐇 ⚫ and rework fake_data.py some more to get realistic data so that I can rap my head around this ticket. So this blocked again 😦

@kaguillera
Copy link
Contributor Author

screen shot 2016-10-03 at 4 16 31 pm

Initial look of the history page. Give me a little feedback before please. Ignore the data. Since before I properly put this PR for review I have to fix fake_data.py again in order to show realistic data and thus do proper testing of the page.

@mattbk
Copy link
Contributor

mattbk commented Oct 4, 2016

Is "Received From" breaking anonymity here?

@kaguillera
Copy link
Contributor Author

I was thinking that just did not have any idea what would be appropriate
hence the post to see if anyone had suggestions. Over the next few days I
will show other possible ways to present the data. Hopefully

On Oct 4, 2016 10:19 AM, "mattbk" [email protected] wrote:

Is "Received From" breaking anonymity here?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#4128 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABNTSW0tdYgdtXiELGyiVXl5AABnZ0joks5qwmB0gaJpZM4KEFSz
.

@kaguillera kaguillera mentioned this pull request Oct 20, 2016
@kaguillera
Copy link
Contributor Author

Once #4150 is merged I will be able to finish this and put this for review

@kaguillera
Copy link
Contributor Author

Please review this. I still have to do the export link that would produce the data for export via csv or excel but I think that this can be merged and the export aspect can be done in another PR. Oh that is once it passes in travis.

@kaguillera
Copy link
Contributor Author

Oh and @whit537 I think that I got the same 150+ commit issue due to programming on the bus. I forced the push so that it would not ruin the history of the logs but I really need to find the root of this problem because I think that it will eventually come back to bite me.

@kaguillera
Copy link
Contributor Author

Burr????

screen shot 2016-11-03 at 8 16 18 pm

Any ideas???
I did not touch that 🙀

@chadwhitacre
Copy link
Contributor

Sorry, @kaguillera. :-(

Working on the build in #4173 ...

@kaguillera
Copy link
Contributor Author

No Problem...I don't think there is any need to rush this.

@kaguillera
Copy link
Contributor Author

Ready for review again. Rebased (at least I think so)

@chadwhitacre
Copy link
Contributor

Rebased, was 118d18b.

@chadwhitacre
Copy link
Contributor

@kaguillera I'm seeing trailing whitespace. Can you configure your editor to remove that when saving?

@chadwhitacre chadwhitacre changed the title Team history page Project history page Jan 4, 2017
@chadwhitacre
Copy link
Contributor

This needs to be updated in light of https://gratipay.news/from-teams-to-projects-45c46718507b.

@kaguillera
Copy link
Contributor Author

Will do

@kaguillera
Copy link
Contributor Author

Ready for review and merging @mattbk @whit537 @nobodxbodon et. al

@nobodxbodon
Copy link
Contributor

I'd be glad to merge as soon as I see a screenshot that shows a demo page (or first thing on Monday without a screenshot), even if I can't fully review it before that. I don't think it's worthwhile to postpone this even more, given the fact that this is a standalone feature and shouldn't impact existing critical features.

if not payments:
return payments

#return payments
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this can be removed?

from decimal import Decimal as D


def get_end_of_year_totals(db, team, year):
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be a good idea to be clear on what format we're expecting arguments in: Is team supposed to be a Team object, or just the team slug? (The latter is the correct answer 🥇 )

I'd suggest using a docstring to describe what the arguments should be, and try passing Team objects around as far as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok will do.

AND direction='to-team';
""", locals() )

if received is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're using COALESCE, I don't think received will ever be None. Will it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True.

AND direction='to-participant';
""", locals())

if distributed is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

return received, distributed


def iter_team_payday_events(db, team, year=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should keep year as an optional here, it already defaults to current_year in the template ( year = int(request.qs.get('year', current_year)) ).

Not that this is wrong, just that it is one more thing to maintain :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough.

payments = db.all("""
SELECT payments.*, paydays.ts_start
FROM payments, paydays
WHERE payments.payday = paydays.id
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a use case for JOIN query.

ie. Instead of

SELECT payments.*, paydays.ts_start
FROM payments, paydays
WHERE payments.payday = paydays.id

use a single JOIN:

SELECT payments.*, paydays.ts_start
FROM payments JOIN paydays ON payments.payday = paydays.id

I find that easier to read (the intent of having multiple tables + their relationship is clear), and from what I've read - databases can do more intelligent optimizations with JOINs compared to multiple SELECTs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will try.


events = []
payday_id = payments[0]['payday']
payday_date = payments[0]['ts_start']
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest naming ts_start as payday_start so that it is clear that it is the start of the payday and not the payment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

#return payments

for payment in payments:
if payment['payday'] != payday_id:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be simplified using itertools.groupby, it does exactly what we're doing here.

Here's what I think this will look like with using groupby:

Before:

events = []
payday_id = payments[0]['payday']
payday_date = payments[0]['ts_start']
payday_events = []

if not payments:
    return payments

#return payments

for payment in payments:
    if payment['payday'] != payday_id:
        events.append (dict(id=payday_id, date=payment['ts_start'], events=payday_events))
        payday_id = payment['payday']
        payday_date = payment['ts_start']
        payday_events = []

    payday_events.append(payment)

events.append (dict(id=payday_id, date=payday_date, events=payday_events))

After:

events = []

grouped_payments = groupby(payments, lambda x: x['payday_id'])
for payday_id, payments in grouped_payments:
	events.append (dict(id=payday_id, date=payments[0]['payday_start'], events=payday_events))

Copy link
Contributor Author

@kaguillera kaguillera Mar 22, 2017

Choose a reason for hiding this comment

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

the entire day I have been trying to unpack that structure that you suggested @rohitpaulk and it is only giving me the last event i.e. the payout to the owner, every time I try to iterate over the events

Copy link
Contributor Author

@kaguillera kaguillera Mar 22, 2017

Choose a reason for hiding this comment

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

The following code (this is just an attempt at understanding the structure of the resulting object) should in theory produce a list with the payday_id, payday_date and list out all the transactions for that payday (unformatted)

{% for payday in events %}
    {% set id = payday['id'] %}
    {% set paydate = payday['date'] %}
    {% set pay_events = payday['events'] %}
    {% print id %}
    <br/>
    {% print paydate %}
    <br/>
    {% for each in pay_events %}
        {% print each %}
    {% endfor %}
    <br/>
    <br/>

{% endfor %}

But it does not it produces the following
screen shot 2017-03-22 at 7 50 09 pm

Any suggestions???
Am I doing something wrong that I can't see.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah - I'll try to take a look at this tonight

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going to give this one another try...

raise Response(400, "Bad Year")
years = list(range(current_year, team.ctime.year-1, -1))

if year not in years:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this check would be clearer if we explicitly checked for if year > current_year, rather than relying on the fact that if x > y, range(y, x, -1) would not contain x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Idea here was to ensure that a person will not put a year in the URL and that year could be greater than the current year or less than the year the team/project 'ctime`

<td class="debits"></td>
{% else %}
<td class="credits"></td>
<td class="notes"> Anonymous </td>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the taker be anonymous here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Changed in d54faa7.

@rohitpaulk
Copy link
Contributor

Had a quick glance through, left comments

@mattbk
Copy link
Contributor

mattbk commented Mar 19, 2017

!m @rohitpaulk

@mattbk
Copy link
Contributor

mattbk commented Mar 21, 2017

Current status:
image

@mattbk
Copy link
Contributor

mattbk commented Mar 21, 2017

Oops.
image

ETA: Travis timed out.

@chadwhitacre
Copy link
Contributor

Travis timeout is likely #4359.

@kaguillera
Copy link
Contributor Author

Ready for final review once again.

@mattbk
Copy link
Contributor

mattbk commented Apr 6, 2017

LGTM

@mattbk
Copy link
Contributor

mattbk commented Apr 12, 2017

puts his finger on the button...

@mattbk mattbk merged commit 66f5f1b into master Apr 12, 2017
@mattbk mattbk deleted the team-history-page branch April 12, 2017 16:39
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.

5 participants