Closed mrwilson closed 3 years ago
Thanks for this!
I've been going back and forward with what I think a good interface it. At a high level I think a timetable
property is right, but I can't decide if the return value should be Dict[str,Dict]
or List[str,Dict]
, where the list is ordered by the date - that is, so the timetable is in order.
I thought that an OrderedDict
might be useful in the Python interface, but it might not translate well if that result were to be served up over JSON downstream.
Did you consider this? What do you think?
I'm happy with any of the below options, they each have advantages / disadvantages.
I suppose if you're looking for a timetable, you're not picking out particular dates so label might be less useful.
I think sorting should be a client-side thing - we can provide it ordered, but consumers shouldn't rely on us providing an ordered list unless we specify, in my opinion? Especially as you say, if we're serialising as JSON for consumers.
# List[Dict]
[{
"label": "Publish date",
"date": date(2020,1,1)
}]
# List[<Custom type>]
[
TimetableEntry("Publish date", date(2020,1,1))
]
I thinking more about this - I think List[Dict]
is the best for now - we can consider a custom type later, but I don't see that it adds a huge amount at the moment.
Wonderful, will perform a release this evening 👍🏻
This PR creates a
timetable
property onElection
objects, which returns aDict[str,Dict]
representing known dates and their "names".The intention is that this property will enable creation of user-facing tables / grids with entire timetables for a given election.
Resolves https://github.com/DemocracyClub/uk-election-timetables/issues/7