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

Description

Database table storing flag records for both automated duplicate detections and manual flags. Each record links to the activities table, carries a flag_type (duplicate | manual), detection_source (on_create | batch | manual), status (open | resolved | dismissed), resolution notes, and the IDs of conflicting activities when applicable. Supports the composite index requirement on (peer_mentor_id, activity_date, organization_id) on the activities table.

Feature: Activity Flagging

activity-flags-table

Responsibilities

  • Persist flag records with full provenance: source, type, actor, timestamps
  • Store references to conflicting activity IDs for duplicate alerts
  • Track flag lifecycle transitions: open → resolved or open → dismissed
  • Serve as the data source for the duplicate alert widget and flagged activity queries

Interfaces

insertFlag(flag: FlagRecord): Promise<string>
updateFlagStatus(flagId: string, status: FlagStatus, resolution?: string): Promise<void>
getFlagsByOrg(orgId: string, status?: FlagStatus): Promise<FlagRecord[]>
getFlagByActivityId(activityId: string): Promise<FlagRecord | null>
getOpenFlagCount(orgId: string): Promise<number>