question 231 Debugging & Logging · easy
Pushes per repository are wrong
A dashboard counts pushes per repository from a day of GitHub events. It says octo/api had one push when the event log shows two, and a repository whose only push was the first event of the day is missing entirely. Reproduce it with the small list in the starter (work out the right answer by hand first), find both bugs and fix push_counts.
Function
push_counts(events)eventsa list of dictionaries with
id, type and repo, in the order they happenedReturnsa dictionary from repository to its number of
PushEvents; repositories with no pushes don't appearExamples
callpush_counts([{'id': '2489651045', 'type': 'PushEvent', 'repo': 'octo/api'}, {'id': '2489651051', 'type': 'WatchEvent', 'repo': 'octo/api'}, {'id': '2489651057', 'type': 'PushEvent', 'repo': 'rails/rails'}, {'id': '2489651064', 'type': 'PushEvent', 'repo': 'octo/api'}])returns{'octo/api': 2, 'rails/rails': 1}
callpush_counts([{'id': '1', 'type': 'PushEvent', 'repo': 'pallets/flask'}])returns{'pallets/flask': 1}
callpush_counts([{'id': '1', 'type': 'WatchEvent', 'repo': 'octo/api'}, {'id': '2', 'type': 'PushEvent', 'repo': 'octo/api'}])returns{'octo/api': 1}