Skip to content

Add metrics projection consumer #1149

Open

Description

@dgee2

Goal

Add a hosted service that consumes engagement outbox events and maintains the RecipeMetricsSnapshot counters.

Spec reference

docs/specs/recipe-creation-target-architecture.md — §"Related recipe usage capabilities – Metrics and engagement"

Implementation notes

  • RecipeMetricsConsumer : BackgroundService polls outbox for unprocessed events:
    • RecipeViewed (isAuthenticated=true) → increment AuthenticatedViewCount, update LastViewedAtUtc
    • RecipeViewed (isAuthenticated=false) → increment PublicViewCount, update LastViewedAtUtc
    • RecipeFavorited → increment FavoriteCount
    • RecipeUnfavorited → decrement FavoriteCount (floor 0)
    • RecipeDiaryEntryPlanned → increment PlannedCount
    • RecipeDiaryEntryCooked → increment CookedCount, update LastCookedAtUtc
  • Upsert snapshot row (create if not exists)

Acceptance criteria

  • Each event type increments the correct counter
  • RecipeViewed routes to correct counter via isAuthenticated flag

Testing

  • Integration tests: emit each event type, run consumer polling cycle, assert correct snapshot field incremented

Part of#1106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net codeenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions