Last active
March 27, 2020 21:20
-
-
Save lcoenen/10f4941923a547a1239b8a15e9a14e54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ngOnInit(): void { | |
const histories$ = this.route.paramMap.pipe( | |
mergeMap(params => { | |
const classNames = params.get('class').split(','); | |
const methodNames = params.get('method').split(','); | |
const metricNames = params.get('metric').split(','); | |
const labelMetric = ([className, methodName, metricName]) => { | |
if (countBy(metricNames)[metricName] >= 2) { | |
if (countBy(methodNames)[methodName] >= 2) { | |
return `${className}::${methodName}() #${metricName}`; | |
} | |
return `${methodName}() #${metricName}`; | |
} | |
return `#${metricName}`; | |
}; | |
const result = zip(classNames, methodNames, metricNames).map(address => { | |
const [className, methodName, metricName] = address; | |
return this.metricsService | |
.getMetricHistory$(className, methodName, metricName) | |
.pipe(map(history => ({history, label: labelMetric(address)}))); | |
}); | |
return forkJoin(result); | |
}), | |
); | |
this.chartData$ = histories$.pipe( | |
map(histories => | |
histories.map(({label, history}) => ({ | |
data: history.map(point => point.value), | |
label, | |
})), | |
), | |
); | |
this.chartLabels$ = histories$.pipe( | |
/* Why is it unknown? */ | |
map((histories: Array<{history: Array<{time: string}>}>) => | |
histories[0].history.map(point => point.time), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment