Data Layer medium complexity backend
0
Dependencies
0
Dependents
0
Entities
0
Integrations

Description

Data access layer responsible for persisting and retrieving flag records from the database. Provides filtered queries for the review queue with support for pagination, category filtering, and multi-level organisation scoping. Owns the flag schema and any related index definitions.

Feature: Activity Flagging

flagged-activity-repository

Sources & reasoning

Line 330 establishes Aktivitetsoversikt as the MVP admin capability. Flagging is an enhancement beyond basic review, needed for the organizational scale described in line 109. It is not listed in the Phase 1 MVP admin scope so Phase 2 ordinal applies, mapping to v1.0.

  • - Aktivitetsoversikt og grunnleggende statistikk
  • - **Bredest organisasjonsstruktur:** 12 landsforeninger, 9 regioner, 1 400 lokallag - aktivitetsfordeling mellom ledd må støttes.

Responsibilities

  • Insert, update, and soft-delete flag records in the flags table
  • Query flags by activity ID, organisation scope, category, and resolution status
  • Return paginated review queue results ordered by raised date
  • Maintain audit fields such as raised_by, resolved_by, and timestamps
  • Enforce unique active-flag constraint per activity to prevent duplicates

Interfaces

insertFlag(flag: NewFlag): Promise<Flag>
updateFlag(flagId: string, updates: Partial<Flag>): Promise<Flag>
findByActivityId(activityId: string): Promise<Flag[]>
findReviewQueue(orgId: string, page: number, limit: number, filters: FlagQueueFilters): Promise<Flag[]>
countActive(orgId: string): Promise<number>