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)
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)
`