openlittermap/openlittermap-web/metrics-pipeline
Claude Code and agent skill by openlittermap/openlittermap-web
- community
Checking that the SKILL.md file is still in the repository.
MetricsService, RedisMetricsCollector, ProcessPhotoMetrics, metrics table, Redis stats, leaderboards, XP processing, and photo processing state (processed_at/fp/tags/xp).
Install
npx vskill@latest install openlittermap/openlittermap-web/metrics-pipelineSKILL.md
The same SKILL.md was published earlier as openlittermap/openlittermap-web/metrics-pipeline.
Metrics Pipeline
MetricsService is the single writer for all metrics — MySQL time-series and Redis aggregates. Nothing else touches metric counters. This is the golden rule.
Key Files
app/Services/Metrics/MetricsService.php— Single writer for MySQL + Redisapp/Services/Redis/RedisMetricsCollector.php— Redis operations (stats, HLL, rankings, tags)app/Services/Redis/RedisKeys.php— All Redis key builders (single source of truth for naming)app/Listeners/Metrics/ProcessPhotoMetrics.php— Queued listener onTagsVerifiedByAdminapp/Events/TagsVerifiedByAdmin.php— Trigger event for metrics processingapp/Enums/LocationType.php— Global(0), Country(1), State(2), City(3) with scope prefixes
Invariants
- Single writer rule. Only
MetricsServicewrites to themetricstable and Redis metric keys. No other code may increment/decrement counters. - Processing state is four columns:
processed_at,processed_fp,processed_tags,processed_xp. A photo withprocessed_at = nullhas never affected aggregates. - Fingerprint-based idempotency. MetricsService diffs old
processed_tagsJSON against new summary and writes only non-zero deltas. Safe to call repeatedly on any photo. - Summary must exist before metrics fire.
GeneratePhotoSummaryService::run()MUST be called beforeTagsVerifiedByAdmindispatches. MetricsService reads fromphoto.summary. - Redis is a derived cache. Rebuildable from the
metricstable.RedisKeys::*is single source of truth for key naming. - `processed_xp` must be INT UNSIGNED, not TINYINT. Overflow bug documented in migration
2026_02_23_182605. - Tags count excludes categories to avoid double-counting:
tags_count = objects + materials + brands + custom_tags. - `ProcessPhotoMetrics` logs a warning when photo not found. If a photo is soft-deleted before the queued listener runs,
ProcessPhotoMetrics::handle()logs a warning and returns gracefully. It does NOT throw or retry.
Patterns
How MetricsService processes a photo
MySQL upsert across timescales and locations
Each photo writes up to 40 rows: 5 timescales (all-time, daily, weekly, monthly, yearly) x 4 location scopes (global, country, state, city) x 2 (aggregate user_id=0 + per-user user_id>0).
Uploads delta: +1 for create, 0 for update, -1 for delete. GREATEST(..., 0) prevents negative counters.
Redis operations happen after MySQL commit
Redis key patterns (cluster-safe with hash tags)
Where TagsVerifiedByAdmin fires
- Non-school users tag a photo:
AddTagsToPhotoAction::updateVerification()— dispatches immediately after summary + XP (both web and mobile use this path). - Teacher approves school photos:
TeamPhotosController::approve()— dispatches per photo after atomicis_public = trueupdate.
Delete flow (metrics reversal)
In Redis, the delete operation also prunes zero-XP members from leaderboard ZSETs:
This keeps Redis consistent with MySQL (which filters xp > 0).
Common Mistakes
- Writing metrics outside MetricsService. Never
DB::table('metrics')->increment(...)orRedis::hincrby(...)directly. - Dispatching `TagsVerifiedByAdmin` before summary generation. MetricsService reads
photo.summary— null summary = zero metrics. - Comparing `processed_xp` as TINYINT. Values above 127 overflow. Column must be UNSIGNED INT.
- Forgetting row locking. Always use
Photo::whereKey($id)->lockForUpdate()->first()inside the transaction. - Assuming Redis is source of truth. Redis is a cache. The
metricstable is authoritative. - Including categories in `tags_count`. Categories are groupings, not countable items. Only objects + materials + brands + custom_tags.
- Not logging when `ProcessPhotoMetrics` can't find the photo.
ProcessPhotoMetricslogs a warning (Log::warning(...)) when the photo is not found (soft-deleted or missing). It does not throw — the job completes successfully to avoid retries. - Using `is_public` as the upload metrics gate.
UploadPhotoControllergatesrecordUploadMetrics()on$team->isSchool(), NOT on$photo->is_public. Private-by-choice photos (non-school) still get immediate upload XP. Only school photos defer metrics to teacher approval.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.ai/skills/metrics-pipeline/SKILL.md
Popularity
- Repository stars
- 130
- Repository forks
- 42
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 31 May 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/openlittermap/openlittermap-web/metrics-pipeline)