Open
Conversation
Track AI slop detection results per provider (Spotify AI Blocker, Soul Over AI, SHLabs, Human Made) with database counters, metrics collection for both InfluxDB and Prometheus, and display in user and global statistics views.
📝 WalkthroughWalkthroughAdds AI-slop detection: four new per-provider counters, DB schema and ORM fields, service builder support, Prometheus and Influx collectors, queue integration to increment counters, and Telegram UI + locale strings to surface totals and breakdowns. Changes
Sequence DiagramsequenceDiagram
participant Queue as Track Queue
participant Service as UserService
participant DB as Database
participant Metrics as Metrics Collector
participant Prometheus as Prometheus
participant InfluxDB as InfluxDB
Queue->>Service: increase_stats_query(user_id).ai_slop(provider)
Service->>DB: UPDATE user SET ai_slop_* = ai_slop_* + 1
DB-->>Service: OK
Metrics->>Service: get_stats(user_id)
Service->>DB: SELECT coalesce(ai_slop_*, 0)...
DB-->>Service: UserStats (includes ai_slop_*)
Service-->>Metrics: ai_slop values
Metrics->>Prometheus: set ai_slop_detection_total[label=provider]
Metrics->>InfluxDB: write measurement "ai_slop_detection"
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/metrics/prometheus.rs`:
- Around line 115-121: The context message for the ai_slop_detection metric
registration is a copy-paste leftover referencing "lyrics_source"; update the
context string used after register_int_gauge_vec_with_registry for
ai_slop_detection to mention "ai_slop_detection" (or a matching descriptive
message) so the .context("Failed to register ...") call correctly identifies the
ai_slop_detection metric when reporting errors.
In `@src/queue/track_check.rs`:
- Around line 279-282: The UserService::increase_stats_query call inside
check_ai_slop currently awaits .exec(...) and propagates errors, causing
check_ai_slop to return early; change it to a best-effort fire-and-forget (or
swallow/log errors) so failures don't abort the rest of check_ai_slop's
skip/notify logic. Specifically, wrap the await in a non-fallible path: spawn a
background task or .await and catch/map_err to log the error via your logger (or
ignore) instead of using the ? operator, leaving check_ai_slop to continue
execution even if UserService::increase_stats_query(...).exec(app.db()).await
fails.
In `@src/services/user.rs`:
- Around line 74-84: The ai_slop builder method currently buckets solely by
provider, which misclassifies cases where AISlopDetectionResult.prediction and
provider must be considered together; change the signature of ai_slop (in
src/services/user.rs) to accept the prediction (or the whole
AISlopDetectionResult) and map buckets from the tuple (prediction, provider)
instead of provider alone, e.g. treat (HumanMade, Some(_)) and (HumanMade, None)
as HumanMade bucket, treat (AIMade, Some(SpotifyAIBlocker)) as
AISlopSpotifyAIBlocker, handle the fail-open path (provider: None, prediction:
HumanMade) as HumanMade, and update the col selection logic that currently uses
UserColumn::AISlopSpotifyAIBlocker / AISlopSoulOverAI / AISlopSHLabs /
AISlopHumanMade accordingly so Expr::col(col).add(1) increments the correct
bucket.
In `@src/telegram/actions/admin_users/details.rs`:
- Around line 121-124: The ai_slop_total calculation incorrectly includes
stats.ai_slop_human_made (and the same inclusion in the later block around the
second occurrence), which makes the "AI Slop Detection" total include non-AI
results; change the ai_slop_total expression to sum only the provider buckets
(stats.ai_slop_spotify_ai_blocker + stats.ai_slop_soul_over_ai +
stats.ai_slop_shlabs) and remove stats.ai_slop_human_made from both occurrences,
or alternatively rename the variable/label to something like checks_total if you
intend to keep human_made included.
In `@src/telegram/actions/global_stats.rs`:
- Around line 53-59: The ai_slop ratio computations can divide by zero when
ai_slop_total == 0; update the logic in src/telegram/actions/global_stats.rs
around the ai_slop_* variables to check ai_slop_total before dividing (use
ai_slop_total > 0) and compute the four ratios
(ai_slop_spotify_ai_blocker_ratio, ai_slop_soul_over_ai_ratio,
ai_slop_shlabs_ratio, ai_slop_human_made_ratio) only when the total is nonzero,
otherwise set them to 0.0 (or an explicit safe value) so no NaN appears in the
Telegram output; reference the ai_slop_total, ai_slop_spotify_ai_blocker_ratio,
ai_slop_soul_over_ai_ratio, ai_slop_shlabs_ratio, and ai_slop_human_made_ratio
symbols when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 9db1abbe-546d-4fb3-b6ae-9e42c9620d0e
📒 Files selected for processing (11)
locales/actions.ymlmigrations/20260308152848_add_ai_slop_detection_counters.sqlsrc/entity/user.rssrc/metrics/influx_collector.rssrc/metrics/prometheus.rssrc/metrics/prometheus_collector.rssrc/queue/track_check.rssrc/services/user.rssrc/telegram/actions/admin_users/details.rssrc/telegram/actions/global_stats.rssrc/telegram/actions/stats.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Track AI slop detection results per provider (Spotify AI Blocker, Soul Over AI, SHLabs, Human Made) with database counters, metrics collection for both InfluxDB and Prometheus, and display in user and global statistics views.