From: Luke Kenneth Casson Leighton Date: Fri, 7 May 2021 14:08:28 +0000 (+0100) Subject: accumulate payment info into rows by bug id X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f4c212e0729cba6c30857f962c52631dbb3b8a2b;p=utils.git accumulate payment info into rows by bug id --- diff --git a/src/budget_sync/main.py b/src/budget_sync/main.py index 3964134..5075603 100644 --- a/src/budget_sync/main.py +++ b/src/budget_sync/main.py @@ -91,12 +91,12 @@ def main(): all_people = OrderedDict() # pre-initialise the CSV lists (to avoid overwrite) for milestone, payments in budget_graph.milestone_payments.items(): - milestone_csvs[milestone] = [] # rows in the CSV file + milestone_csvs[milestone] = {} # rows in the CSV file for milestone, payments in budget_graph.milestone_payments.items(): # first get the list of people, then create some columns people = milestones_people[milestone] - headings = [] + headings = ['bug_id'] for person in people: name = str(person).replace(" ", "_") all_people[person] = person @@ -106,8 +106,11 @@ def main(): headings.append(name+"_paid") milestone_headings[milestone] = headings # now we go through the whole "payments" thing again... - row = {} for payment in payments: + row = milestone_csvs[milestone].get(payment.node.id, None) + if row is None: + row = {'bug_id': payment.node.id} + name = str(payment.payee.identifier).replace(" ", "_") row[name+"_amount"] = str(payment.amount) if payment.submitted is not None: @@ -120,8 +123,9 @@ def main(): paid = "" row[name+"_req"] = requested row[name+"_paid"] = paid + print (row) - milestone_csvs[milestone].append(row) + milestone_csvs[milestone][payment.node.id] = row if args.output_dir is not None: with open("%s/csvs.mdwn" % args.output_dir, "w") as f: @@ -136,6 +140,7 @@ def main(): ident = milestone.identifier header = milestone_headings[milestone] fname = "%s/%s.csv" % (args.output_dir, ident) + rows = rows.values() # turn into list write_csv(fname, rows, header) f.write(mdwn_csv_template % (ident, fname))