Implement AnimalTagged and AnimalTagEnded event handling: - Add migration for tag_suggestions table - Create TagProjection for tag intervals and suggestions - Update EventAnimalsProjection to handle tag events - Add add_tag() and end_tag() to AnimalService Key behaviors: - No-op idempotence (adding active tag or ending inactive tag) - Updates live_animals_by_location.tags JSON array - Tracks tag usage statistics in tag_suggestions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
16 lines
565 B
SQL
16 lines
565 B
SQL
-- ABOUTME: Migration to create tag_suggestions table.
|
|
-- ABOUTME: Tracks tag usage for autocomplete in the UI.
|
|
|
|
-- Tag suggestions for autocomplete
|
|
-- Updated synchronously during tagging operations
|
|
CREATE TABLE tag_suggestions (
|
|
tag TEXT PRIMARY KEY,
|
|
total_assignments INTEGER NOT NULL DEFAULT 0,
|
|
active_animals INTEGER NOT NULL DEFAULT 0,
|
|
last_used_utc INTEGER,
|
|
updated_at_utc INTEGER NOT NULL
|
|
);
|
|
|
|
-- Index for sorting by popularity
|
|
CREATE INDEX idx_tag_suggestions_popularity ON tag_suggestions(active_animals DESC, total_assignments DESC);
|