@@ -9,8 +9,8 @@ import * as React from 'react';
99import Chart from 'react-apexcharts' ;
1010import { CONVERT_REPORTED_METRICS_NAME , REPORTED_METRICS , TRANSACTION_PER_MINUTE , USE_CASE } from '../../common/Constant' ;
1111import { usePageEffect } from '../../core/page' ;
12- import { CommitInformation , PerformanceTrendData , ServiceCommitInformation , TrendData } from './data' ;
13- import { GetPerformanceTrendData } from './service' ;
12+ import { PerformanceTrendData , ServiceCommitInformation , TrendData } from './data' ;
13+ import { GetPerformanceTrendData , GetServiceCommitInformation } from './service' ;
1414import { PasswordDialog } from '../../common/Dialog' ;
1515import { BasedOptionChart } from './styles' ;
1616
@@ -188,10 +188,11 @@ export default function PerformanceTrend(props: { password: string; password_is_
188188 const use_case = ctx . opts . series . at ( seriesIndex ) ?. name ;
189189 const selected_data = series [ seriesIndex ] [ dataPointIndex ] ;
190190 const selected_hash = w . globals . categoryLabels [ dataPointIndex ] ;
191- const selected_hash_information = commits_information . filter ( ( c : CommitInformation ) => c . sha === selected_hash ) . at ( 0 ) ;
192-
193- const commit_history = selected_hash_information ?. commit_message . replace ( / \n \r * \n * / g, '<br />' ) ;
194- const commited_by = selected_hash_information ?. commit_date + ' commited by @' + selected_hash_information ?. commiter_name ;
191+ const selected_hash_information : ServiceCommitInformation | undefined = commits_information
192+ . filter ( ( c : ServiceCommitInformation ) => c . sha === selected_hash )
193+ . at ( 0 ) ;
194+ const commit_history = selected_hash_information ?. commit . message . replace ( / \n \r * \n * / g, '<br />' ) ;
195+ const commited_by = `Committed by ${ selected_hash_information ?. author . login } on ${ selected_hash_information ?. author . date } ` ;
195196 const commit_data = `<b>${ use_case } </b>: ${ selected_data } ` ;
196197
197198 return (
@@ -231,7 +232,7 @@ function useStatePerformanceTrend(password: string) {
231232 last_update : undefined as string | undefined ,
232233 hash_categories : [ ] as number [ ] ,
233234 trend_data : [ ] as TrendData [ ] ,
234- commits_information : [ ] as CommitInformation [ ] ,
235+ commits_information : [ ] as ServiceCommitInformation [ ] ,
235236 } ) ;
236237
237238 React . useEffect ( ( ) => {
@@ -249,50 +250,55 @@ function useStatePerformanceTrend(password: string) {
249250 // With ScanIndexForward being set to true, the trend data are being sorted descending based on the CommitDate.
250251 // Therefore, the first data that has commit date is the latest commit.
251252 const commit_date = performances . at ( 0 ) ?. CommitDate . N || '' ;
252- const hash_categories = Array . from ( new Set ( performances . map ( ( p ) => p . CommitHash . S . substring ( 0 , 6 ) ) ) ) . reverse ( ) ;
253+ const hash_categories = Array . from ( new Set ( performances . map ( ( p ) => p . CommitHash . S . substring ( 0 , 7 ) ) ) ) . reverse ( ) ;
253254 // Get all the information for the hash categories in order to get the commiter name, the commit message, and the releveant information
254- // const commits_information = await Promise.all(hash_categories.map((hash) => GetServiceCommitInformation(hash)));
255- const commits_information : ServiceCommitInformation [ ] = hash_categories . map ( ( hash ) => {
256- return {
257- author : { login : 'Login' } ,
258- commit : { message : 'Message' , committer : { date : '1/1/99' } } ,
259- sha : hash ,
260- } ;
261- } ) ;
262- const final_commits_information : CommitInformation [ ] = commits_information . map ( ( c ) => {
263- return {
264- commiter_name : c . author . login ,
265- commit_message : c . commit . message ,
266- commit_date : c . commit . committer . date ,
267- sha : c . sha . substring ( 0 , 7 ) ,
268- } ;
269- } ) ;
255+ const commits_information = await Promise . all ( hash_categories . map ( ( hash ) => GetServiceCommitInformation ( password , hash ) ) ) ;
270256
271257 /* Generate series of data that has the following format:
272258 data_rate: transaction per minute
273259 data_series: [{…}]
274260 data_type: metrics or traces or logs
275261 name: metric_name
276262 */
263+
277264 for ( const metric of REPORTED_METRICS ) {
278265 for ( const tpm of TRANSACTION_PER_MINUTE ) {
279266 for ( const data_type of [ 'metrics' , 'traces' , 'logs' ] ) {
280267 const typeGrouping = performances . filter ( ( p ) => p . DataType . S === data_type ) ;
281268 if ( typeGrouping . length === 0 ) {
282269 continue ;
283270 }
284- const data_series : { name : string ; data : number [ ] } [ ] = [ ] ;
271+ const data_series : {
272+ name : string ;
273+ data : {
274+ y : number ;
275+ x : string ;
276+ } [ ] ;
277+ } [ ] = [ ] ;
278+
285279 for ( const use_case of USE_CASE ) {
286- const data = typeGrouping
280+ const rawData = typeGrouping
287281 . reverse ( )
288282 . filter ( ( d ) => d . UseCase . S === use_case )
289283 . map ( ( p ) => {
290284 try {
291- return Number ( Number ( p . Results . M [ tpm ] . M [ metric ] . M . Average ?. N ) . toFixed ( 2 ) ) ;
285+ return {
286+ y : Number ( Number ( p . Results . M [ tpm ] . M [ metric ] . M . Average ?. N ) . toFixed ( 2 ) ) ,
287+ x : p . CommitHash . S . substring ( 0 , 7 ) ,
288+ } ;
292289 } catch ( e ) {
293- return - 1 ;
290+ return {
291+ y : - 1 ,
292+ x : p . CommitHash . S . substring ( 0 , 7 ) ,
293+ } ;
294294 }
295295 } ) ;
296+
297+ const data : {
298+ y : number ;
299+ x : string ;
300+ } [ ] = rawData . filter ( ( a ) => a ?. y !== - 1 && a ?. y !== undefined ) ;
301+
296302 if ( data . length === 0 ) {
297303 continue ;
298304 }
@@ -314,7 +320,7 @@ function useStatePerformanceTrend(password: string) {
314320 ...prev ,
315321 trend_data : trend_data ,
316322 hash_categories : hash_categories ,
317- commits_information : final_commits_information ,
323+ commits_information : commits_information ,
318324 last_update : moment . unix ( Number ( commit_date ) ) . format ( 'dddd, MMMM Do, YYYY h:mm:ss A' ) ,
319325 } ) ) ;
320326 } ) ( ) ;
0 commit comments