fix: revert to embedded activity chart data to resolve loading failures
This commit is contained in:
@@ -31,7 +31,7 @@ A collection of enhancements, plugins, and prompts for [OpenWebUI](https://githu
|
|||||||
| 6️⃣ | [Markdown Normalizer](https://openwebui.com/posts/markdown_normalizer_baaa8732) |  |  |  |  |
|
| 6️⃣ | [Markdown Normalizer](https://openwebui.com/posts/markdown_normalizer_baaa8732) |  |  |  |  |
|
||||||
|
|
||||||
### 📈 Total Downloads Trend
|
### 📈 Total Downloads Trend
|
||||||

|

|
||||||
|
|
||||||
*See full stats and charts in [Community Stats Report](./docs/community-stats.md)*
|
*See full stats and charts in [Community Stats Report](./docs/community-stats.md)*
|
||||||
<!-- STATS_END -->
|
<!-- STATS_END -->
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ OpenWebUI 增强功能集合。包含个人开发与收集的插件、提示词
|
|||||||
| 6️⃣ | [Markdown Normalizer](https://openwebui.com/posts/markdown_normalizer_baaa8732) |  |  |  |  |
|
| 6️⃣ | [Markdown Normalizer](https://openwebui.com/posts/markdown_normalizer_baaa8732) |  |  |  |  |
|
||||||
|
|
||||||
### 📈 总下载量累计趋势
|
### 📈 总下载量累计趋势
|
||||||

|

|
||||||
|
|
||||||
*完整统计与趋势图请查看 [社区统计报告](./docs/community-stats.zh.md)*
|
*完整统计与趋势图请查看 [社区统计报告](./docs/community-stats.zh.md)*
|
||||||
<!-- STATS_END -->
|
<!-- STATS_END -->
|
||||||
|
|||||||
@@ -1134,50 +1134,20 @@ class OpenWebUIStats:
|
|||||||
|
|
||||||
print(f"✅ README 已更新: {readme_path}")
|
print(f"✅ README 已更新: {readme_path}")
|
||||||
|
|
||||||
def upload_chart_data(self, stats: dict):
|
def generate_activity_chart(self, lang: str = "zh") -> str:
|
||||||
"""上传图表数据到 Gist (独立于徽章数据)"""
|
"""生成 Vega-Lite 趋势图 (内嵌数据,确保稳定性)"""
|
||||||
if not (self.gist_token and self.gist_id):
|
|
||||||
return
|
|
||||||
|
|
||||||
history = self.load_history()
|
history = self.load_history()
|
||||||
if len(history) < 3:
|
if len(history) < 3:
|
||||||
return
|
|
||||||
|
|
||||||
# 准备图表数据点
|
|
||||||
chart_data = []
|
|
||||||
for item in history:
|
|
||||||
chart_data.append(
|
|
||||||
{"date": item["date"], "downloads": item["total_downloads"]}
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
url = f"https://api.github.com/gists/{self.gist_id}"
|
|
||||||
headers = {"Authorization": f"token {self.gist_token}"}
|
|
||||||
payload = {
|
|
||||||
"files": {
|
|
||||||
"chart-data.json": {
|
|
||||||
"content": json.dumps(chart_data, ensure_ascii=False, indent=2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resp = requests.patch(url, headers=headers, json=payload)
|
|
||||||
if resp.status_code == 200:
|
|
||||||
print(f"✅ 图表数据已同步至 Gist")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"⚠️ 图表数据同步失败: {e}")
|
|
||||||
|
|
||||||
def generate_activity_chart(self, lang: str = "zh") -> str:
|
|
||||||
"""生成 Vega-Lite 趋势图 (使用外部数据源,URL 固定)"""
|
|
||||||
if not (self.gist_token and self.gist_id):
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
# 准备数据点
|
||||||
|
values = []
|
||||||
|
for item in history:
|
||||||
|
values.append({"date": item["date"], "downloads": item["total_downloads"]})
|
||||||
|
|
||||||
title = "Total Downloads Trend" if lang == "en" else "总下载量累计趋势"
|
title = "Total Downloads Trend" if lang == "en" else "总下载量累计趋势"
|
||||||
|
|
||||||
# 使用 Gist Raw URL 作为数据源
|
# Vega-Lite Spec (内嵌数据)
|
||||||
gist_user = "Fu-Jie"
|
|
||||||
data_url = f"https://gist.githubusercontent.com/{gist_user}/{self.gist_id}/raw/chart-data.json"
|
|
||||||
|
|
||||||
# Vega-Lite Spec (数据从外部 URL 加载)
|
|
||||||
vl_spec = {
|
vl_spec = {
|
||||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"description": title,
|
"description": title,
|
||||||
@@ -1189,7 +1159,7 @@ class OpenWebUIStats:
|
|||||||
"view": {"stroke": "transparent"},
|
"view": {"stroke": "transparent"},
|
||||||
"axis": {"domain": False, "grid": False},
|
"axis": {"domain": False, "grid": False},
|
||||||
},
|
},
|
||||||
"data": {"url": data_url}, # 外部数据源
|
"data": {"values": values},
|
||||||
"mark": {
|
"mark": {
|
||||||
"type": "area",
|
"type": "area",
|
||||||
"line": {"color": "#2563eb"},
|
"line": {"color": "#2563eb"},
|
||||||
@@ -1220,7 +1190,7 @@ class OpenWebUIStats:
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Kroki encoding for Vega-Lite (spec 固定,URL 也固定)
|
# Kroki encoding for Vega-Lite
|
||||||
json_spec = json.dumps(vl_spec)
|
json_spec = json.dumps(vl_spec)
|
||||||
compressed = zlib.compress(json_spec.encode("utf-8"), level=9)
|
compressed = zlib.compress(json_spec.encode("utf-8"), level=9)
|
||||||
encoded = base64.urlsafe_b64encode(compressed).decode("utf-8")
|
encoded = base64.urlsafe_b64encode(compressed).decode("utf-8")
|
||||||
@@ -1296,9 +1266,7 @@ def main():
|
|||||||
stats_client.save_json(stats, str(json_path))
|
stats_client.save_json(stats, str(json_path))
|
||||||
|
|
||||||
# 生成 Shields.io endpoint JSON (用于动态徽章)
|
# 生成 Shields.io endpoint JSON (用于动态徽章)
|
||||||
badges_dir = script_dir / "docs"
|
badges_dir = script_dir / "docs" / "badges"
|
||||||
# 上传图表数据到 Gist (独立存储)
|
|
||||||
stats_client.upload_chart_data(stats)
|
|
||||||
|
|
||||||
# 生成徽章
|
# 生成徽章
|
||||||
stats_client.generate_shields_endpoints(stats, str(badges_dir))
|
stats_client.generate_shields_endpoints(stats, str(badges_dir))
|
||||||
|
|||||||
Reference in New Issue
Block a user