github-statistics 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. github_statistics/__init__.py +14 -0
  2. github_statistics/__main__.py +10 -0
  3. github_statistics/_version.py +24 -0
  4. github_statistics/cli/__init__.py +9 -0
  5. github_statistics/cli/app.py +104 -0
  6. github_statistics/cli/cache.py +159 -0
  7. github_statistics/cli/collect.py +219 -0
  8. github_statistics/cli/common.py +128 -0
  9. github_statistics/cli/config.py +80 -0
  10. github_statistics/cli/doctor.py +214 -0
  11. github_statistics/cli/export.py +111 -0
  12. github_statistics/cli/options.py +175 -0
  13. github_statistics/cli/render.py +126 -0
  14. github_statistics/cli/run.py +137 -0
  15. github_statistics/cli/scope.py +96 -0
  16. github_statistics/cli/site.py +150 -0
  17. github_statistics/client/__init__.py +40 -0
  18. github_statistics/client/accounting.py +99 -0
  19. github_statistics/client/budget.py +125 -0
  20. github_statistics/client/cooldown.py +113 -0
  21. github_statistics/client/errors.py +60 -0
  22. github_statistics/client/graphql.py +281 -0
  23. github_statistics/client/paging.py +92 -0
  24. github_statistics/client/policy.py +243 -0
  25. github_statistics/client/transport.py +437 -0
  26. github_statistics/collect/__init__.py +44 -0
  27. github_statistics/collect/common.py +69 -0
  28. github_statistics/collect/enrich_items.py +423 -0
  29. github_statistics/collect/items.py +238 -0
  30. github_statistics/collect/jobs.py +194 -0
  31. github_statistics/collect/listed.py +42 -0
  32. github_statistics/collect/members.py +70 -0
  33. github_statistics/collect/reader.py +124 -0
  34. github_statistics/collect/run.py +354 -0
  35. github_statistics/collect/runs.py +436 -0
  36. github_statistics/collect/slices.py +55 -0
  37. github_statistics/collect/steps.py +154 -0
  38. github_statistics/collect/sweep.py +70 -0
  39. github_statistics/config/__init__.py +37 -0
  40. github_statistics/config/loader.py +430 -0
  41. github_statistics/config/models.py +156 -0
  42. github_statistics/config/schema.py +245 -0
  43. github_statistics/export/__init__.py +11 -0
  44. github_statistics/export/csv.py +93 -0
  45. github_statistics/export/documents.py +189 -0
  46. github_statistics/export/json.py +33 -0
  47. github_statistics/py.typed +2 -0
  48. github_statistics/render/__init__.py +44 -0
  49. github_statistics/render/bars3d.py +420 -0
  50. github_statistics/render/charts.py +214 -0
  51. github_statistics/render/demo.py +133 -0
  52. github_statistics/render/images.py +31 -0
  53. github_statistics/render/layout.py +341 -0
  54. github_statistics/render/model.py +260 -0
  55. github_statistics/render/palette.py +41 -0
  56. github_statistics/scope/__init__.py +17 -0
  57. github_statistics/scope/apply.py +95 -0
  58. github_statistics/scope/resolver.py +228 -0
  59. github_statistics/series/__init__.py +22 -0
  60. github_statistics/series/actors.py +128 -0
  61. github_statistics/series/coverage.py +86 -0
  62. github_statistics/series/daily.py +229 -0
  63. github_statistics/series/leaderboard.py +221 -0
  64. github_statistics/series/repositories.py +154 -0
  65. github_statistics/site/__init__.py +9 -0
  66. github_statistics/site/assets/site.css +281 -0
  67. github_statistics/site/build.py +392 -0
  68. github_statistics/site/templates/base.html.j2 +25 -0
  69. github_statistics/site/templates/index.html.j2 +30 -0
  70. github_statistics/site/templates/macros.html.j2 +5 -0
  71. github_statistics/site/templates/site.js.j2 +66 -0
  72. github_statistics/site/templates/target.html.j2 +95 -0
  73. github_statistics/store/__init__.py +40 -0
  74. github_statistics/store/activity.py +311 -0
  75. github_statistics/store/aggregates.py +294 -0
  76. github_statistics/store/base.py +163 -0
  77. github_statistics/store/codec.py +263 -0
  78. github_statistics/store/models.py +136 -0
  79. github_statistics/store/paths.py +36 -0
  80. github_statistics/store/schema.py +169 -0
  81. github_statistics/store/sqlite.py +299 -0
  82. github_statistics-0.1.0.dist-info/METADATA +308 -0
  83. github_statistics-0.1.0.dist-info/RECORD +86 -0
  84. github_statistics-0.1.0.dist-info/WHEEL +4 -0
  85. github_statistics-0.1.0.dist-info/entry_points.txt +2 -0
  86. github_statistics-0.1.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,245 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: 2026 The Linux Foundation
3
+ """The JSON Schema for the configuration document, and its validation.
4
+
5
+ Every object sets ``additionalProperties: false``, so a misspelt key
6
+ fails loudly instead of being ignored. There is deliberately no
7
+ ``scan_private`` key: private repositories are out of scope by design.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from collections.abc import Mapping
13
+ from typing import Any
14
+
15
+ from jsonschema import Draft202012Validator
16
+ from jsonschema.exceptions import ValidationError, best_match
17
+
18
+ IDENTITY_KEYS = ("org_bots", "external_bots", "members", "member_orgs", "ignore_logins")
19
+ CLASS_KEYS = ("all", "member", "external", "org_bot", "external_bot", "humans", "bots")
20
+ CONTRIBUTOR_COLUMNS = ("merged_by", "closed_by")
21
+ PALETTE_KEYS = ("opened", "closed", "runs", "jobs", "succeeded", "failed")
22
+ WINDOW_MIN_DAYS = 7
23
+ WINDOW_MAX_DAYS = 730
24
+
25
+ _STRINGS: dict[str, Any] = {
26
+ "type": "array",
27
+ "items": {"type": "string", "minLength": 1},
28
+ }
29
+
30
+ _IDENTITIES: dict[str, Any] = {
31
+ "type": "object",
32
+ "additionalProperties": False,
33
+ "properties": dict.fromkeys(IDENTITY_KEYS, _STRINGS),
34
+ }
35
+
36
+ _TARGET: dict[str, Any] = {
37
+ "type": "object",
38
+ "additionalProperties": False,
39
+ "required": ["owner"],
40
+ "properties": {
41
+ "owner": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9-]*$"},
42
+ "token_env": {"type": "string", "minLength": 1},
43
+ "include": _STRINGS,
44
+ "exclude": _STRINGS,
45
+ "scan_archived": {"type": "boolean"},
46
+ "scan_forks": {"type": "boolean"},
47
+ "scan_templates": {"type": "boolean"},
48
+ "identities": {"$ref": "#/$defs/identities"},
49
+ },
50
+ # include and exclude may not both be non-empty (design §5).
51
+ "not": {
52
+ "required": ["include", "exclude"],
53
+ "properties": {
54
+ "include": {"minItems": 1},
55
+ "exclude": {"minItems": 1},
56
+ },
57
+ },
58
+ }
59
+
60
+
61
+ def _object(properties: dict[str, Any]) -> dict[str, Any]:
62
+ """A closed object schema: only the named keys are allowed."""
63
+ return {"type": "object", "additionalProperties": False, "properties": properties}
64
+
65
+
66
+ SCHEMA: dict[str, Any] = {
67
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
68
+ "title": "github-statistics configuration",
69
+ "type": "object",
70
+ "additionalProperties": False,
71
+ "required": ["targets"],
72
+ "$defs": {"identities": _IDENTITIES},
73
+ "properties": {
74
+ "version": {"const": 1},
75
+ "identities": {"$ref": "#/$defs/identities"},
76
+ "targets": {"type": "array", "minItems": 1, "items": _TARGET},
77
+ "window": _object(
78
+ {
79
+ "days": {
80
+ "type": "integer",
81
+ "minimum": WINDOW_MIN_DAYS,
82
+ "maximum": WINDOW_MAX_DAYS,
83
+ },
84
+ }
85
+ ),
86
+ "metrics": _object(
87
+ dict.fromkeys(
88
+ ("pull_requests", "issues", "workflows", "workflow_outcomes"),
89
+ {"type": "boolean"},
90
+ )
91
+ ),
92
+ "classes": {
93
+ "type": "array",
94
+ "minItems": 1,
95
+ "uniqueItems": True,
96
+ "items": {"enum": list(CLASS_KEYS)},
97
+ },
98
+ "render": _object(
99
+ {
100
+ "width": {"type": "integer", "minimum": 1},
101
+ "height": {"type": "integer", "minimum": 1},
102
+ "derivatives": {
103
+ "type": "array",
104
+ "items": {"type": "integer", "minimum": 1},
105
+ },
106
+ "svg": {"type": "boolean"},
107
+ "palette": _object(
108
+ dict.fromkeys(
109
+ PALETTE_KEYS,
110
+ {"type": "string", "pattern": "^#[0-9A-Fa-f]{6}$"},
111
+ )
112
+ ),
113
+ "back_on_tie": _object(
114
+ {
115
+ "pull_requests": {"enum": ["opened", "closed"]},
116
+ "issues": {"enum": ["opened", "closed"]},
117
+ "workflows": {"enum": ["runs", "jobs"]},
118
+ }
119
+ ),
120
+ }
121
+ ),
122
+ "contributors": _object(
123
+ {
124
+ "top_n": {"type": "integer", "minimum": 0},
125
+ "columns": {
126
+ "type": "array",
127
+ "uniqueItems": True,
128
+ "items": {"enum": list(CONTRIBUTOR_COLUMNS)},
129
+ },
130
+ }
131
+ ),
132
+ "budget": _object(
133
+ {
134
+ "rest": {"type": "integer", "minimum": 1},
135
+ "graphql_points": {"type": "integer", "minimum": 10},
136
+ "reserve": {"type": ["integer", "null"], "minimum": 0},
137
+ }
138
+ ),
139
+ "output": _object({"directory": {"type": "string", "minLength": 1}}),
140
+ "cache": _object({"directory": {"type": ["string", "null"], "minLength": 1}}),
141
+ },
142
+ }
143
+
144
+ _VALIDATOR = Draft202012Validator(SCHEMA)
145
+
146
+
147
+ class ConfigError(Exception):
148
+ """The configuration cannot be found, read, parsed or validated."""
149
+
150
+
151
+ class NoConfigurationError(ConfigError):
152
+ """No configuration source exists: no flag, no ``$GHS_CONFIG``, no default file."""
153
+
154
+
155
+ def _location(error: ValidationError) -> str:
156
+ """Render the path to a failing value as ``targets[0].window``."""
157
+ parts: list[str] = []
158
+ for part in error.absolute_path:
159
+ if isinstance(part, int):
160
+ parts.append(f"[{part}]")
161
+ else:
162
+ parts.append(f".{part}" if parts else str(part))
163
+ return "".join(parts) or "configuration"
164
+
165
+
166
+ def _plural(count: Any, noun: str) -> str:
167
+ """``1 item`` or ``2 items``."""
168
+ return f"{count} {noun}" if count == 1 else f"{count} {noun}s"
169
+
170
+
171
+ def _expected(value: Any) -> str:
172
+ """Name an expected JSON type, or a choice of types."""
173
+ if isinstance(value, list):
174
+ return " or ".join(str(item) for item in value)
175
+ return str(value)
176
+
177
+
178
+ def _message(error: ValidationError) -> str:
179
+ """Turn one validation error into a one-line reason.
180
+
181
+ The reason comes from the failing constraint alone and never quotes
182
+ the rejected value, which may be a token pasted in the wrong place.
183
+ Unknown keys are named, since a misspelt key is the point of the error.
184
+ """
185
+ validator = error.validator
186
+ value: Any = error.validator_value
187
+ if validator == "not":
188
+ return "include and exclude may not both be non-empty"
189
+ if validator == "additionalProperties" and isinstance(error.instance, dict):
190
+ schema = error.schema
191
+ known = schema.get("properties", {}) if isinstance(schema, Mapping) else {}
192
+ unknown = sorted(key for key in error.instance if key not in known)
193
+ return "unknown key " + ", ".join(repr(key) for key in unknown)
194
+ if validator == "required" and isinstance(error.instance, dict):
195
+ missing = [key for key in value if key not in error.instance]
196
+ return "missing required key " + ", ".join(repr(key) for key in missing)
197
+ match validator:
198
+ case "type":
199
+ return f"expected {_expected(value)}"
200
+ case "enum":
201
+ return "expected one of " + ", ".join(repr(item) for item in value)
202
+ case "const":
203
+ return f"expected {value!r}"
204
+ case "pattern":
205
+ return f"does not match {value}"
206
+ case "minLength":
207
+ return f"must be at least {_plural(value, 'character')}"
208
+ case "minimum":
209
+ return f"must be at least {value}"
210
+ case "maximum":
211
+ return f"must be at most {value}"
212
+ case "minItems":
213
+ return f"must have at least {_plural(value, 'item')}"
214
+ case "uniqueItems":
215
+ return "must not repeat an item"
216
+ return f"fails the {validator} constraint"
217
+
218
+
219
+ def validate(data: Any) -> None:
220
+ """Validate a parsed configuration document; raise `ConfigError` on failure.
221
+
222
+ The error names the most relevant failing location and its reason
223
+ on one line, so ``config check`` can print it as it is.
224
+ """
225
+ error = best_match(_VALIDATOR.iter_errors(data))
226
+ if error is not None:
227
+ raise ConfigError(f"{_location(error)}: {_message(error)}")
228
+ _check_owners(data["targets"])
229
+
230
+
231
+ def _check_owners(targets: list[dict[str, Any]]) -> None:
232
+ """Reject a second target for an owner, compared case-insensitively.
233
+
234
+ Each owner gets one page, one cache and one set of target settings,
235
+ and ``--org``/``--repo`` select a target by owner, so a second target
236
+ for the same owner would silently replace the first.
237
+ """
238
+ seen: dict[str, int] = {}
239
+ for index, target in enumerate(targets):
240
+ first = seen.setdefault(target["owner"].lower(), index)
241
+ if first != index:
242
+ raise ConfigError(
243
+ f"targets[{index}].owner: repeats targets[{first}].owner; "
244
+ "use one target per owner"
245
+ )
@@ -0,0 +1,11 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: 2026 The Linux Foundation
3
+ """Export: the published dataset under ``<output>/<owner>/data/`` (design §8.6)."""
4
+
5
+ from __future__ import annotations
6
+
7
+ from .csv import write_csv
8
+ from .documents import build_documents
9
+ from .json import compact, write_json
10
+
11
+ __all__ = ["build_documents", "compact", "write_csv", "write_json"]
@@ -0,0 +1,93 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: 2026 The Linux Foundation
3
+ """CSV files, one per table, from the export documents (design §8.6).
4
+
5
+ ``series.csv`` is in long form, one row per metric, series, class and
6
+ day; ``coverage.csv`` one row per metric and day; the contributor,
7
+ repository and review tables one row per record. The runs horizon and
8
+ the run metadata have no table and stay in the JSON export.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import csv
14
+ from collections.abc import Iterator, Mapping
15
+ from pathlib import Path
16
+ from typing import Any
17
+
18
+ Table = tuple[list[str], list[list[Any]]]
19
+
20
+
21
+ def _series(document: Mapping[str, Any]) -> Table:
22
+ """The long-form rows of ``series.json``."""
23
+ rows: list[list[Any]] = []
24
+ for metric, data in sorted(document["metrics"].items()):
25
+ for series, classes in sorted(data["series"].items()):
26
+ for actor_class, points in sorted(classes.items()):
27
+ rows.extend(
28
+ [metric, series, actor_class, point["day"], point["value"]]
29
+ for point in points
30
+ )
31
+ return ["metric", "series", "class", "day", "value"], rows
32
+
33
+
34
+ def _coverage(document: Mapping[str, Any]) -> Table:
35
+ """One row per metric and day, from the per-day coverage in ``series.json``."""
36
+ rows = [
37
+ [metric, point["day"], point["coverage"]]
38
+ for metric, data in sorted(document["metrics"].items())
39
+ for point in data["coverage"]
40
+ ]
41
+ return ["metric", "day", "coverage"], rows
42
+
43
+
44
+ def _contributors(document: Mapping[str, Any]) -> Table:
45
+ """The leaderboard, one row per contributor."""
46
+ header = ["login", "class", *document["columns"]]
47
+ return header, [[row[key] for key in header] for row in document["contributors"]]
48
+
49
+
50
+ def _repositories(document: Mapping[str, Any]) -> Table:
51
+ """The repository table, with one ``coverage_<metric>`` column per metric."""
52
+ metrics = document["metrics"]
53
+ rows = document["repositories"]
54
+ counts = document["columns"]
55
+ header = ["repository", *counts, *(f"coverage_{metric}" for metric in metrics)]
56
+ body = [
57
+ [
58
+ row["repository"],
59
+ *(row[key] for key in counts),
60
+ *(row["coverage"][metric] for metric in metrics),
61
+ ]
62
+ for row in rows
63
+ ]
64
+ return header, body
65
+
66
+
67
+ def _reviews(document: Mapping[str, Any]) -> Table:
68
+ """One row per review."""
69
+ header = ["repository", "number", "reviewer", "class", "state", "submitted_at"]
70
+ return header, [[row[key] for key in header] for row in document["reviews"]]
71
+
72
+
73
+ def tables(documents: Mapping[str, Any]) -> Iterator[tuple[str, Table]]:
74
+ """Each CSV table, by file stem, built from the export documents."""
75
+ yield "series", _series(documents["series"])
76
+ yield "coverage", _coverage(documents["series"])
77
+ yield "contributors", _contributors(documents["contributors"])
78
+ yield "repositories", _repositories(documents["repositories"])
79
+ yield "reviews", _reviews(documents["reviews"])
80
+
81
+
82
+ def write_csv(documents: Mapping[str, Any], directory: Path) -> list[Path]:
83
+ """Write each table to ``<directory>/<name>.csv``; the paths, sorted."""
84
+ directory.mkdir(parents=True, exist_ok=True)
85
+ paths = []
86
+ for name, (header, rows) in tables(documents):
87
+ path = directory / f"{name}.csv"
88
+ with path.open("w", encoding="utf-8", newline="") as handle:
89
+ writer = csv.writer(handle, lineterminator="\n")
90
+ writer.writerow(header)
91
+ writer.writerows(rows)
92
+ paths.append(path)
93
+ return sorted(paths)
@@ -0,0 +1,189 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: 2026 The Linux Foundation
3
+ """The documents a target publishes under ``data/`` (design §8.6).
4
+
5
+ Each document is self-contained plain data built from the store and
6
+ the configuration alone: the window end and the generation date are
7
+ passed in, and nothing here reads a clock or makes a request.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from datetime import date
13
+ from typing import Any
14
+
15
+ from ..collect import runs_horizon
16
+ from ..config import Config, ResolvedIdentities, Target, resolve_identities
17
+ from ..config.loader import dump
18
+ from ..render.model import Coverage
19
+ from ..series import (
20
+ TargetSeries,
21
+ build_leaderboard,
22
+ build_repositories,
23
+ build_series,
24
+ classify,
25
+ )
26
+ from ..series.actors import normalise, public_members
27
+ from ..series.leaderboard import BOT_TYPE, display_login, leaderboard_columns
28
+ from ..series.repositories import COLUMNS as REPOSITORY_COLUMNS
29
+ from ..store import Store
30
+ from ..store.codec import timestamp
31
+
32
+ # The name each coverage grade takes in ``coverage.json``.
33
+ COVERAGE_NAMES = {
34
+ Coverage.COMPLETE: "complete",
35
+ Coverage.PARTIAL: "partial",
36
+ Coverage.NONE: "missing",
37
+ }
38
+ Documents = dict[str, dict[str, Any]]
39
+
40
+
41
+ def _series(owner: str, built: TargetSeries) -> dict[str, Any]:
42
+ """``series.json``: per metric, series and class, one ``{day, value}`` per day."""
43
+ days = [day.isoformat() for day in built.days]
44
+ metrics: dict[str, Any] = {
45
+ metric: {
46
+ "coverage": [
47
+ {"day": day, "coverage": grade.value}
48
+ for day, grade in zip(days, grades, strict=True)
49
+ ],
50
+ "series": {},
51
+ }
52
+ for metric, grades in built.coverage.items()
53
+ }
54
+ for (metric, series, actor_class), values in built.counts.items():
55
+ classes = metrics[metric]["series"].setdefault(series, {})
56
+ classes[actor_class] = [
57
+ {"day": day, "value": value}
58
+ for day, value in zip(days, values, strict=True)
59
+ ]
60
+ return {"owner": owner, "metrics": metrics}
61
+
62
+
63
+ def _coverage(owner: str, built: TargetSeries, horizon: date | None) -> dict[str, Any]:
64
+ """``coverage.json``: per metric, the days complete, partial and missing."""
65
+ metrics = {}
66
+ for metric, grades in built.coverage.items():
67
+ named: dict[str, list[str]] = {name: [] for name in COVERAGE_NAMES.values()}
68
+ for day, grade in zip(built.days, grades, strict=True):
69
+ named[COVERAGE_NAMES[grade]].append(day.isoformat())
70
+ metrics[metric] = named
71
+ return {
72
+ "owner": owner,
73
+ "runs_horizon": horizon.isoformat() if horizon else None,
74
+ "metrics": metrics,
75
+ }
76
+
77
+
78
+ def _reviews(
79
+ store: Store,
80
+ target: Target,
81
+ identities: ResolvedIdentities,
82
+ days: tuple[date, ...],
83
+ ) -> dict[str, Any]:
84
+ """``reviews.json``: every review in the window, its reviewer and class.
85
+
86
+ Reviews of repositories out of scope on the day, and of ignored
87
+ logins, are left out, as everywhere else.
88
+ """
89
+ scope = {day: set(store.in_scope(day)) for day in days}
90
+ members = public_members(store, identities, owner=target.owner)
91
+ reviews = store.reviews_between(days[0], days[-1])
92
+ forms: dict[str, set[str]] = {}
93
+ bots: set[str] = set()
94
+ for review in reviews:
95
+ if review.reviewer is not None:
96
+ key = normalise(review.reviewer)
97
+ forms.setdefault(key, set()).add(review.reviewer)
98
+ if review.reviewer_type == BOT_TYPE:
99
+ bots.add(key)
100
+ shown = {
101
+ key: display_login(found, identities, bot=key in bots)
102
+ for key, found in forms.items()
103
+ }
104
+ records = []
105
+ for review in reviews:
106
+ if review.submitted_at is None:
107
+ continue
108
+ if review.repo not in scope.get(review.submitted_at.date(), set()):
109
+ continue
110
+ actor_class = classify(
111
+ review.reviewer, review.reviewer_type, identities, members
112
+ )
113
+ if actor_class is None:
114
+ continue
115
+ reviewer = review.reviewer
116
+ records.append(
117
+ {
118
+ "repository": review.repo,
119
+ "number": review.number,
120
+ "reviewer": shown[normalise(reviewer)] if reviewer else None,
121
+ "class": actor_class.value,
122
+ "state": review.state,
123
+ "submitted_at": timestamp(review.submitted_at),
124
+ }
125
+ )
126
+ return {"owner": target.owner, "reviews": records}
127
+
128
+
129
+ def build_documents(
130
+ store: Store,
131
+ config: Config,
132
+ target: Target,
133
+ *,
134
+ until: date,
135
+ generated: date,
136
+ version: str,
137
+ identities: ResolvedIdentities | None = None,
138
+ ) -> Documents:
139
+ """Every document of ``target``, keyed by file stem.
140
+
141
+ ``until`` ends the window, ``generated`` is the date recorded in
142
+ ``meta.json`` and ``version`` the tool version recorded beside it.
143
+ """
144
+ if identities is None:
145
+ identities = resolve_identities(target, config)
146
+ owner = target.owner
147
+ built = build_series(store, config, target, until=until, identities=identities)
148
+ contributors = build_leaderboard(
149
+ store, config, target, until=until, identities=identities
150
+ )
151
+ repositories = build_repositories(
152
+ store, config, target, until=until, identities=identities
153
+ )
154
+ horizon = runs_horizon(store, owner)
155
+ return {
156
+ "series": _series(owner, built),
157
+ "contributors": {
158
+ "owner": owner,
159
+ "columns": list(leaderboard_columns(config)),
160
+ "contributors": [row.record() for row in contributors],
161
+ },
162
+ "repositories": {
163
+ "owner": owner,
164
+ "columns": list(REPOSITORY_COLUMNS),
165
+ "metrics": list(built.coverage),
166
+ "repositories": [row.record() for row in repositories],
167
+ },
168
+ "coverage": _coverage(owner, built, horizon),
169
+ "reviews": _reviews(store, target, identities, built.days),
170
+ "meta": {
171
+ "tool_version": version,
172
+ "target": owner,
173
+ "window": {
174
+ "days": len(built.days),
175
+ "from": built.days[0].isoformat(),
176
+ "until": built.days[-1].isoformat(),
177
+ },
178
+ "scope_rule": {
179
+ "include": list(target.include),
180
+ "exclude": list(target.exclude),
181
+ "scan_archived": target.scan_archived,
182
+ "scan_forks": target.scan_forks,
183
+ "scan_templates": target.scan_templates,
184
+ },
185
+ "generated": generated.isoformat(),
186
+ "unclassified_bots": list(built.unclassified_bots),
187
+ "identities": dump(identities),
188
+ },
189
+ }
@@ -0,0 +1,33 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: 2026 The Linux Foundation
3
+ """Compact JSON files, one self-contained document each (design §8.6).
4
+
5
+ No indent, no spaces after separators, sorted keys and UTF-8 text, so a
6
+ fixed store gives byte-identical files and a large ``reviews.json``
7
+ stays a fraction of its pretty-printed size.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ from collections.abc import Mapping
14
+ from pathlib import Path
15
+ from typing import Any
16
+
17
+
18
+ def compact(document: Any) -> str:
19
+ """``document`` as compact JSON text with sorted keys."""
20
+ return json.dumps(
21
+ document, separators=(",", ":"), sort_keys=True, ensure_ascii=False
22
+ )
23
+
24
+
25
+ def write_json(documents: Mapping[str, Any], directory: Path) -> list[Path]:
26
+ """Write each document to ``<directory>/<name>.json``; the paths, sorted."""
27
+ directory.mkdir(parents=True, exist_ok=True)
28
+ paths = []
29
+ for name in sorted(documents):
30
+ path = directory / f"{name}.json"
31
+ path.write_text(compact(documents[name]), encoding="utf-8")
32
+ paths.append(path)
33
+ return paths
@@ -0,0 +1,2 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: 2026 The Linux Foundation
@@ -0,0 +1,44 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: 2026 The Linux Foundation
3
+ """The 2.5D chart renderer: plain data in, PNG files out, no network."""
4
+
5
+ from __future__ import annotations
6
+
7
+ from .bars3d import render_chart
8
+ from .charts import TargetChart, render_target
9
+ from .images import write_derivatives
10
+ from .layout import plan_chart
11
+ from .model import (
12
+ Bar,
13
+ Box,
14
+ ChartPlan,
15
+ ChartSpec,
16
+ Coverage,
17
+ GapSpan,
18
+ MonthLabel,
19
+ Peak,
20
+ PeakLabel,
21
+ RenderedChart,
22
+ Series,
23
+ Style,
24
+ )
25
+
26
+ __all__ = [
27
+ "Bar",
28
+ "Box",
29
+ "ChartPlan",
30
+ "ChartSpec",
31
+ "Coverage",
32
+ "GapSpan",
33
+ "MonthLabel",
34
+ "Peak",
35
+ "PeakLabel",
36
+ "RenderedChart",
37
+ "Series",
38
+ "Style",
39
+ "TargetChart",
40
+ "plan_chart",
41
+ "render_chart",
42
+ "render_target",
43
+ "write_derivatives",
44
+ ]