Home / Function/ computePeriodTotal() — supabase Function Reference

computePeriodTotal() — supabase Function Reference

Architecture documentation for the computePeriodTotal() function in ReportChartV2.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  752e39f1_bf41_9daa_fe02_d71ad3fd9e60["computePeriodTotal()"]
  41f16ebe_2bcb_fb78_ddd7_d9584fbfa8d3["ReportChartV2()"]
  41f16ebe_2bcb_fb78_ddd7_d9584fbfa8d3 -->|calls| 752e39f1_bf41_9daa_fe02_d71ad3fd9e60
  style 752e39f1_bf41_9daa_fe02_d71ad3fd9e60 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx lines 36–61

export function computePeriodTotal(
  chartData: Record<string, unknown>[],
  dynamicAttributes: MultiAttribute[]
): number {
  const attributeKeys = Array.from(
    new Set(
      dynamicAttributes
        .filter(
          (a) =>
            a?.enabled !== false &&
            a?.provider !== 'reference-line' &&
            !a?.isMaxValue &&
            !a?.omitFromTotal
        )
        .map((a) => a.attribute)
    )
  )

  return chartData.reduce((sum: number, row: Record<string, unknown>) => {
    const rowTotal = attributeKeys.reduce((acc: number, key: string) => {
      const value = row?.[key]
      return acc + (typeof value === 'number' ? value : 0)
    }, 0)
    return sum + rowTotal
  }, 0)
}

Subdomains

Called By

Frequently Asked Questions

What does computePeriodTotal() do?
computePeriodTotal() is a function in the supabase codebase.
What calls computePeriodTotal()?
computePeriodTotal() is called by 1 function(s): ReportChartV2.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free