MCPcopy Create free account
hub / github.com/Marus/cortex-debug / sampleData

Method sampleData

src/grapher/datasource.ts:60–75  ·  view source on GitHub ↗
(graphId: string, sampleSize: number, start: number = null, end: number = null)

Source from the content-addressed store, hash-verified

58 }
59
60 public sampleData(graphId: string, sampleSize: number, start: number = null, end: number = null): GraphPoint[] {
61 let data: GraphPoint[] = this.data[graphId];
62 if (!data) { return []; }
63
64 if (start === null) { start = 0; }
65 if (end == null) { end = new Date().getTime(); }
66
67 data = data.filter((gp) => gp.timestamp >= start && gp.timestamp <= end);
68
69 if (data.length > sampleSize * 1.5) {
70 const sampleRate = Math.round(data.length / sampleSize);
71 data = data.filter((gp, idx) => idx % sampleRate === 0);
72 }
73
74 return data;
75 }
76
77 public oldestPoint(graphId: string): GraphPoint {
78 return this.data[graphId] ? this.data[graphId][0] : null;

Callers 1

updateGraphMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected