Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate decision synopsis #73

Open
alexrandaccio opened this issue Sep 28, 2021 · 0 comments
Open

generate decision synopsis #73

alexrandaccio opened this issue Sep 28, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@alexrandaccio
Copy link
Member

alexrandaccio commented Sep 28, 2021

Is your feature request related to a problem? Please describe.
save time on pulling data from decisions (e.g. voice credits received by each delegate)

Describe the solution you'd like
export a synopsis with this data

Describe alternatives you've considered
I've been doing this myself with a python script that I execute from the Django shell

Additional context
The script:

`import csv
from main.models import Vote, Delegate, Process, Transfer, MatchPayment

fields = ['Voter', 'Credit Balance', 'Effective Votes Cast', 'Voice Credits Spent', 'Transfers Sent', 'Voice Credits Sent', 'Transfers Received', 'Voice Credits Received', 'Match Received']

with open('delegates.csv', 'w') as csvfile:
csvwriter = csv.writer(csvfile)

csvwriter.writerow(fields)

votes = Vote.objects.all().filter(proposal__election__id=13)

p = Process.objects.get(id=13)
delegates = [x for x in p.delegates.all() if x.is_verified]

for delegate in delegates:
    newrow = [delegate.id,
        delegate.credit_balance + sum([vote.amount * vote.amount for vote in votes if vote.sender == delegate and vote.amount != 0]),
        sum([abs(vote.amount) for vote in votes if vote.sender == delegate and vote.amount != 0]),
        sum([vote.amount * vote.amount for vote in votes if vote.sender == delegate and vote.amount != 0]),
        len(set([x.recipient_object for x in Transfer.objects.filter(process__id=13) if x.sender==delegate])),
        sum([x.amount for x in Transfer.objects.filter(process__id=13) if x.sender==delegate]),
        len(set([x.sender for x in Transfer.objects.filter(process__id=13) if x.recipient_object==delegate])),
        sum([x.amount for x in Transfer.objects.filter(process__id=13) if x.recipient_object==delegate]),
        [x.amount for x in MatchPayment.objects.filter(process__id=13) if x.recipient==delegate]]
    csvwriter.writerow(newrow)

`

@alexrandaccio alexrandaccio added the enhancement New feature or request label Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant