From 40af699f6caee94029500508531c93f61b974225 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 12 Jan 2024 19:08:47 -0500 Subject: [PATCH] fix: don't display duplicate runs. #19 --- README.rst | 4 ++++ src/watchgha/data_core.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/README.rst b/README.rst index 5e0be43..d4dc310 100644 --- a/README.rst +++ b/README.rst @@ -187,7 +187,11 @@ Unreleased - Fix: don't fail if a .netrc file can't be found. Fixes `issue 18`_. +- Fix: in the odd case of duplicate remotes, don't list workflow runs twice. + Fixes `issue 19`_. + .. _issue 18: https://github.com/nedbat/watchgha/issues/18 +.. _issue 19: https://github.com/nedbat/watchgha/issues/19 2.2.0 — 2024-01-11 diff --git a/src/watchgha/data_core.py b/src/watchgha/data_core.py index bf84390..1491853 100644 --- a/src/watchgha/data_core.py +++ b/src/watchgha/data_core.py @@ -105,6 +105,11 @@ async def runs_from_url(url): for url in urls: nursery.start_soon(runs_from_url, url) + # In odd situations (duplicate remotes) we can get the same run more than + # once. De-duplicate them. + runs_by_id = {r["id"]: r for r in runs} + runs = list(runs_by_id.values()) + async with trio.open_nursery() as nursery: for run in runs: run["started_dt"] = to_datetime(run["run_started_at"])