mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
clear state.calcs on every append (#33245)
This commit is contained in:
parent
69bcaf9253
commit
408bc06bab
@ -1,3 +1,4 @@
|
||||
import { reduceField, ReducerID } from '..';
|
||||
import { DataFrame, FieldType } from '../types/dataFrame';
|
||||
import { DataFrameJSON } from './DataFrameJSON';
|
||||
import { StreamingDataFrame } from './StreamingDataFrame';
|
||||
@ -200,10 +201,14 @@ describe('Streaming JSON', () => {
|
||||
maxLength: 5,
|
||||
}
|
||||
);
|
||||
let val = reduceField({ field: stream.fields[0], reducers: [ReducerID.lastNotNull] })[ReducerID.lastNotNull];
|
||||
expect(val).toEqual(100);
|
||||
expect(stream.length).toEqual(1);
|
||||
stream.push({
|
||||
data: { values: [[200]] },
|
||||
});
|
||||
val = reduceField({ field: stream.fields[0], reducers: [ReducerID.lastNotNull] })[ReducerID.lastNotNull];
|
||||
expect(val).toEqual(200);
|
||||
expect(stream.length).toEqual(2);
|
||||
|
||||
const copy = ({ ...stream } as any) as DataFrame;
|
||||
|
@ -178,7 +178,11 @@ export class StreamingDataFrame implements DataFrame {
|
||||
let appended = circPush(curValues, values, this.options.maxLength, this.timeFieldIndex, this.options.maxDelta);
|
||||
|
||||
appended.forEach((v, i) => {
|
||||
this.fields[i].values.buffer = v;
|
||||
const { state, values } = this.fields[i];
|
||||
values.buffer = v;
|
||||
if (state) {
|
||||
state.calcs = undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// Update the frame length
|
||||
|
@ -46,6 +46,8 @@ interface ReduceFieldOptions {
|
||||
|
||||
/**
|
||||
* @returns an object with a key for each selected stat
|
||||
* NOTE: This will also modify the 'field.state' object,
|
||||
* leaving values in a cache until cleared.
|
||||
*/
|
||||
export function reduceField(options: ReduceFieldOptions): FieldCalcs {
|
||||
const { field, reducers } = options;
|
||||
|
Loading…
Reference in New Issue
Block a user