From 8511b7df80c62ee90a283a05db8db8ec738e8395 Mon Sep 17 00:00:00 2001 From: fujie Date: Mon, 12 Jan 2026 01:57:15 +0800 Subject: [PATCH] feat: add version column to top plugins stats and optimize workflow --- .github/workflows/community-stats.yml | 32 ++------------------------- scripts/openwebui_stats.py | 8 +++---- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/.github/workflows/community-stats.yml b/.github/workflows/community-stats.yml index 505186e..d8990ba 100644 --- a/.github/workflows/community-stats.yml +++ b/.github/workflows/community-stats.yml @@ -32,16 +32,7 @@ jobs: run: | pip install requests python-dotenv - - name: Get previous stats - id: prev_stats - run: | - # 获取当前的 points 用于比较 - if [ -f docs/community-stats.json ]; then - OLD_POINTS=$(jq -r '.user.total_points' docs/community-stats.json 2>/dev/null || echo "0") - echo "old_points=$OLD_POINTS" >> $GITHUB_OUTPUT - else - echo "old_points=0" >> $GITHUB_OUTPUT - fi + - name: Generate stats report env: @@ -49,27 +40,8 @@ jobs: OPENWEBUI_USER_ID: ${{ secrets.OPENWEBUI_USER_ID }} run: | python scripts/openwebui_stats.py - - - name: Check for significant changes - id: check_changes - run: | - # 获取新的 points - NEW_POINTS=$(jq -r '.user.total_points' docs/community-stats.json 2>/dev/null || echo "0") - - echo "📊 Previous points: ${{ steps.prev_stats.outputs.old_points }}" - echo "📊 Current points: $NEW_POINTS" - - # 只在 points 变化时才 commit - if [ "$NEW_POINTS" != "${{ steps.prev_stats.outputs.old_points }}" ]; then - echo "changed=true" >> $GITHUB_OUTPUT - echo "✅ Points changed (${{ steps.prev_stats.outputs.old_points }} → $NEW_POINTS), will commit" - else - echo "changed=false" >> $GITHUB_OUTPUT - echo "⏭️ Points unchanged, skipping commit" - fi - + - name: Commit and push changes - if: steps.check_changes.outputs.changed == 'true' run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" diff --git a/scripts/openwebui_stats.py b/scripts/openwebui_stats.py index a289c93..e337acf 100644 --- a/scripts/openwebui_stats.py +++ b/scripts/openwebui_stats.py @@ -415,7 +415,7 @@ class OpenWebUIStats: "header": "| 📝 发布 | ⬇️ 下载 | 👁️ 浏览 | 👍 点赞 | 💾 收藏 |", "top6_title": "### 🔥 热门插件 Top 6", "top6_updated": f"> 🕐 自动更新于 {get_beijing_time().strftime('%Y-%m-%d %H:%M')}", - "top6_header": "| 排名 | 插件 | 下载 | 浏览 | 更新日期 |", + "top6_header": "| 排名 | 插件 | 版本 | 下载 | 浏览 | 更新日期 |", "full_stats": "*完整统计请查看 [社区统计报告](./docs/community-stats.zh.md)*", }, "en": { @@ -425,7 +425,7 @@ class OpenWebUIStats: "header": "| 📝 Posts | ⬇️ Downloads | 👁️ Views | 👍 Upvotes | 💾 Saves |", "top6_title": "### 🔥 Top 6 Popular Plugins", "top6_updated": f"> 🕐 Auto-updated: {get_beijing_time().strftime('%Y-%m-%d %H:%M')}", - "top6_header": "| Rank | Plugin | Downloads | Views | Updated |", + "top6_header": "| Rank | Plugin | Version | Downloads | Views | Updated |", "full_stats": "*See full stats in [Community Stats Report](./docs/community-stats.md)*", }, } @@ -467,13 +467,13 @@ class OpenWebUIStats: lines.append(t["top6_updated"]) lines.append("") lines.append(t["top6_header"]) - lines.append("|:---:|------|:---:|:---:|:---:|") + lines.append("|:---:|------|:---:|:---:|:---:|:---:|") medals = ["🥇", "🥈", "🥉", "4️⃣", "5️⃣", "6️⃣"] for i, post in enumerate(top_plugins): medal = medals[i] if i < len(medals) else str(i + 1) lines.append( - f"| {medal} | [{post['title']}]({post['url']}) | {post['downloads']} | {post['views']} | {post['updated_at']} |" + f"| {medal} | [{post['title']}]({post['url']}) | {post['version']} | {post['downloads']} | {post['views']} | {post['updated_at']} |" ) lines.append("")