first commit

This commit is contained in:
Space-Banane
2026-05-29 19:15:00 +02:00
commit a54d1cfeaf
25 changed files with 1183 additions and 0 deletions

42
app/merge.py Normal file
View File

@@ -0,0 +1,42 @@
from collections.abc import Iterable
def merge_activity(
github: dict[str, int],
gitea: dict[str, int],
dates: Iterable[str] | None = None,
) -> dict[str, dict[str, int]]:
keys = set(github) | set(gitea)
if dates is not None:
keys |= set(dates)
merged: dict[str, dict[str, int]] = {}
for date_key in sorted(keys):
gh = int(github.get(date_key, 0))
gt = int(gitea.get(date_key, 0))
merged[date_key] = {
"github": gh,
"gitea": gt,
"total": gh + gt,
}
return merged
def filter_activity_source(
merged: dict[str, dict[str, int]],
source: str,
) -> dict[str, dict[str, int]]:
if source == "all":
return merged
filtered: dict[str, dict[str, int]] = {}
for day, counts in merged.items():
github = counts.get("github", 0)
gitea = counts.get("gitea", 0)
if source == "github":
filtered[day] = {"github": github, "gitea": 0, "total": github}
elif source == "gitea":
filtered[day] = {"github": 0, "gitea": gitea, "total": gitea}
else:
filtered[day] = counts
return filtered