mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
feat(api): add widget_name parameter to render_composite_adhoc function.
This commit is contained in:
@@ -139,8 +139,9 @@ def process_one() -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def render_composite_adhoc(username: str, override_settings: dict) -> str | None:
|
||||
"""Render the composite SVG for `username` using stored settings merged
|
||||
def render_composite_adhoc(username: str, override_settings: dict,
|
||||
widget_name: str = "composite") -> str | None:
|
||||
"""Render `widget_name` for `username` using stored settings merged
|
||||
with the per-request `override_settings`. Does NOT persist anything.
|
||||
|
||||
Used by the public `GET /api/<u>?...` endpoint so unauthenticated visitors
|
||||
@@ -158,11 +159,15 @@ def render_composite_adhoc(username: str, override_settings: dict) -> str | None
|
||||
if not payload or payload.get("error") == "not_found":
|
||||
return None
|
||||
effective = {**settings_row["settings"], **(override_settings or {})}
|
||||
if widget_name != "composite":
|
||||
# Only the requested widget is returned, so don't pay to render the
|
||||
# rest: generate_widgets_from_github skips anything not enabled.
|
||||
effective["enabled"] = [widget_name]
|
||||
t0 = time.monotonic()
|
||||
widgets = _render_widgets(username, payload, effective)
|
||||
analytics.record_render(username, "composite",
|
||||
int((time.monotonic() - t0) * 1000))
|
||||
return widgets.get("composite")
|
||||
return widgets.get(widget_name)
|
||||
|
||||
|
||||
def render_widgets_now(username: str) -> dict[str, str]:
|
||||
|
||||
Reference in New Issue
Block a user