@@ -3,6 +3,7 @@ import * as path from 'path';
33import { QueryHistoryConfig } from './config' ;
44import { LocalQueryInfo , QueryHistoryInfo } from './query-results' ;
55import { RemoteQueryHistoryItem } from './remote-queries/remote-query-history-item' ;
6+ import { pluralize } from './helpers' ;
67
78interface InterpolateReplacements {
89 t : string ; // Start time
@@ -64,17 +65,23 @@ export class HistoryItemLabelProvider {
6465 } ;
6566 }
6667
67- private getRemoteInterpolateReplacements ( item : RemoteQueryHistoryItem ) : InterpolateReplacements {
68+ // Return the number of repositories queried if available. Otherwise, use the controller repository name.
69+ private buildRepoLabel ( item : RemoteQueryHistoryItem ) : string {
6870 const numRepositoriesQueried = item . remoteQuery . numRepositoriesQueried ;
69- const numRepositoriesLabel = `${ numRepositoriesQueried } ${ numRepositoriesQueried === 1 ? 'repository' : 'repositories' } ` ;
71+
72+ if ( numRepositoriesQueried ) {
73+ return pluralize ( numRepositoriesQueried , 'repository' , 'repositories' ) ;
74+ }
75+
76+ return `${ item . remoteQuery . controllerRepository . owner } /${ item . remoteQuery . controllerRepository . name } ` ;
77+ }
78+
79+ private getRemoteInterpolateReplacements ( item : RemoteQueryHistoryItem ) : InterpolateReplacements {
7080 return {
7181 t : new Date ( item . remoteQuery . executionStartTime ) . toLocaleString ( env . language ) ,
7282 q : `${ item . remoteQuery . queryName } (${ item . remoteQuery . language } )` ,
73-
74- // Return the number of repositories queried if available. Otherwise, use the controller repository name.
75- d : numRepositoriesQueried ? numRepositoriesLabel : `${ item . remoteQuery . controllerRepository . owner } /${ item . remoteQuery . controllerRepository . name } ` ,
76-
77- r : item . resultCount === undefined ? '' : `(${ item . resultCount } results)` ,
83+ d : this . buildRepoLabel ( item ) ,
84+ r : `(${ pluralize ( item . resultCount , 'result' , 'results' ) } )` ,
7885 s : item . status ,
7986 f : path . basename ( item . remoteQuery . queryFilePath ) ,
8087 '%' : '%'
0 commit comments