Skip to content

feat(oss): rank content lists by spam score (last-N-days triage)#4856

Merged
mashbean merged 3 commits into
developfrom
feat/oss-spam-ranking
Jun 17, 2026
Merged

feat(oss): rank content lists by spam score (last-N-days triage)#4856
mashbean merged 3 commits into
developfrom
feat/oss-spam-ranking

Conversation

@mashbean

Copy link
Copy Markdown
Contributor

背景

OSS 後台要能「一週內垃圾機率由高到低」檢視文章/動態/留言。但 comment/moment 清單原本只支援 id desc、article 清單沒有依 spam 分數排序。

變更

  • ArticlesSort.mostSpam:依 spam_score 由高到低排序(只含已評分文章)。
  • 新增 OSSCommentsInput / OSSMomentsInputsortOSSContentSpamSort:newest / mostSpam)+ filter.datetimeRange(近 7 天窗)。
  • comments / moments resolver 改用 connectionFromQuery 可排序/篩選;新增 commentService.findComments() 查詢建構子。
  • mostSpamwhereNotNull(spam_score) 排除未評分項,避免 NULLS-first 排序污染排行。
  • schema 產物(schema.graphql / schema.d.ts)手動同步(本機 codegen 版本與 committed 版本漂移,避免無關重排)。

備註

  • 未加 DB 級排序測試(需帶 spam_score 的 fixture);查詢建構簡單,建議於 staging 實測。
  • 對應前端 PR:thematters/matters-oss feat/oss-spam-ranking
  • 本 PR 需先於前端部署(前端送出新的 input 欄位,舊 schema 會拒)。

🤖 Generated with Claude Code

OSS comment/moment lists could only be ordered by id desc and the article
list had no spam-score sort, so admins had no way to surface the most likely
spam across articles/moments/comments.

- ArticlesSort.mostSpam: order scored articles by spam_score desc.
- OSSCommentsInput / OSSMomentsInput: add sort (OSSContentSpamSort) and a
  datetimeRange filter (for the 'last 7 days' window).
- comments/moments resolvers: build sortable/filterable queries via
  connectionFromQuery; commentService.findComments() query builder added.
- mostSpam excludes rows without a spam_score so unscored items don't pollute
  the ranking (and avoids NULLS-first ordering).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mashbean mashbean requested a review from a team as a code owner June 17, 2026 04:40
The oss.moments field input changed from ConnectionArgs to OSSMomentsInput;
update the system test query variable accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.93%. Comparing base (086cd37) to head (915098c).
⚠️ Report is 31 commits behind head on develop.

Files with missing lines Patch % Lines
src/queries/system/oss/articles.ts 0.00% 4 Missing ⚠️
src/queries/system/oss/comments.ts 90.90% 1 Missing ⚠️
src/queries/system/oss/moments.ts 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4856      +/-   ##
===========================================
+ Coverage    72.57%   72.93%   +0.36%     
===========================================
  Files         1067     1068       +1     
  Lines        21164    21541     +377     
  Branches      4619     4802     +183     
===========================================
+ Hits         15360    15712     +352     
- Misses        5327     5347      +20     
- Partials       477      482       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Exercise the mostSpam ranking and datetimeRange filter paths in the OSS
comment/moment list resolvers (and commentService.findComments) to raise
patch coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mashbean mashbean merged commit d8c9a60 into develop Jun 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant