Commit 5b1f0bb0 by Dominik Prokop Committed by Torkel Ödegaard

PanelData: Rename ColumnStats type to FieldStats (#16494)

parent 5bc936d2
......@@ -24,12 +24,12 @@ export enum StatID {
allIsNull = 'allIsNull',
}
export interface ColumnStats {
export interface FieldStats {
[key: string]: any;
}
// Internal function
type StatCalculator = (data: SeriesData, fieldIndex: number, ignoreNulls: boolean, nullAsZero: boolean) => ColumnStats;
type StatCalculator = (data: SeriesData, fieldIndex: number, ignoreNulls: boolean, nullAsZero: boolean) => FieldStats;
export interface StatCalculatorInfo {
id: string;
......@@ -73,7 +73,7 @@ export interface CalculateStatsOptions {
/**
* @returns an object with a key for each selected stat
*/
export function calculateStats(options: CalculateStatsOptions): ColumnStats {
export function calculateStats(options: CalculateStatsOptions): FieldStats {
const { series, fieldIndex, stats, nullValueMode } = options;
if (!stats || stats.length < 1) {
......@@ -85,7 +85,7 @@ export function calculateStats(options: CalculateStatsOptions): ColumnStats {
// Return early for empty series
// This lets the concrete implementations assume at least one row
if (!series.rows || series.rows.length < 1) {
const stats = {} as ColumnStats;
const stats = {} as FieldStats;
for (const stat of queue) {
stats[stat.id] = stat.emptyInputResult !== null ? stat.emptyInputResult : null;
}
......@@ -227,7 +227,7 @@ function standardStatsStat(
fieldIndex: number,
ignoreNulls: boolean,
nullAsZero: boolean
): ColumnStats {
): FieldStats {
const stats = {
sum: 0,
max: -Number.MAX_VALUE,
......@@ -247,7 +247,7 @@ function standardStatsStat(
// Just used for calcutations -- not exposed as a stat
previousDeltaUp: true,
} as ColumnStats;
} as FieldStats;
for (let i = 0; i < data.rows.length; i++) {
let currentValue = data.rows[i][fieldIndex];
......@@ -345,11 +345,11 @@ function standardStatsStat(
return stats;
}
function calculateFirst(data: SeriesData, fieldIndex: number, ignoreNulls: boolean, nullAsZero: boolean): ColumnStats {
function calculateFirst(data: SeriesData, fieldIndex: number, ignoreNulls: boolean, nullAsZero: boolean): FieldStats {
return { first: data.rows[0][fieldIndex] };
}
function calculateLast(data: SeriesData, fieldIndex: number, ignoreNulls: boolean, nullAsZero: boolean): ColumnStats {
function calculateLast(data: SeriesData, fieldIndex: number, ignoreNulls: boolean, nullAsZero: boolean): FieldStats {
return { last: data.rows[data.rows.length - 1][fieldIndex] };
}
......@@ -358,7 +358,7 @@ function calculateChangeCount(
fieldIndex: number,
ignoreNulls: boolean,
nullAsZero: boolean
): ColumnStats {
): FieldStats {
let count = 0;
let first = true;
let last: any = null;
......@@ -387,7 +387,7 @@ function calculateDistinctCount(
fieldIndex: number,
ignoreNulls: boolean,
nullAsZero: boolean
): ColumnStats {
): FieldStats {
const distinct = new Set<any>();
for (let i = 0; i < data.rows.length; i++) {
let currentValue = data.rows[i][fieldIndex];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment