Skip to content

Commit

Permalink
output json from export_history
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesturk committed Feb 14, 2020
1 parent 4aa7755 commit 9939101
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions bulk/management/commands/export_history.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from functools import lru_cache
from collections import defaultdict
from django.core.management.base import BaseCommand
Expand Down Expand Up @@ -154,9 +155,24 @@ def handle_epoch(**kwargs):
# TODO: handle subobjects
for bill_id, changes in changes["bill"].items():
change_obj = make_change_object(changes)
from pprint import pprint
yield change_obj
# for vote_id, changes in changes["vote"].items():
# change_obj = make_change_object(changes)
# yield change_obj


def output_json(epoch, data):
output = {
"version": "0.1",
"source": "https://openstates.org",
"epoch": epoch,
"changes": [],
}
for item in data:
output["changes"].append(item)

pprint(change_obj)
with open(f"changelog_{epoch}.json", "w") as f:
json.dump(output, f, indent=1)


class Command(BaseCommand):
Expand All @@ -170,4 +186,5 @@ def handle(self, *args, **options):
"event_time__hour",
"event_time__minute",
).distinct():
handle_epoch(**time)
formatted = format_time(**time)
output_json(formatted, handle_epoch(**time))

0 comments on commit 9939101

Please sign in to comment.