@@ -14,7 +14,7 @@ const TABLE_ISSUES = 'issues';
1414const TABLE_MERGE_REQUESTS = 'merge_requests' ;
1515const TABLE_TIMES = 'times' ;
1616const TABLE_LABELS = 'labels' ;
17- const TABLE_LABEL_GROUP = 'label_group ' ;
17+ const TABLE_LABEL_GROUP = 'label_groups ' ;
1818const TABLE_MILESTONES = 'milestones' ;
1919
2020const COLUMNS = {
@@ -83,7 +83,9 @@ class Table {
8383 }
8484}
8585
86-
86+ /**
87+ * Promise-based abstraction of the SQLite database driver
88+ */
8789class SqliteDatabaseAbstraction {
8890
8991 constructor ( file ) {
@@ -133,7 +135,8 @@ class SqliteDatabaseAbstraction {
133135 */
134136 insertRecords ( table ) {
135137 return new Promise ( ( resolve , reject ) => {
136- const stmt = this . database . prepare ( `INSERT INTO ${ table . name } VALUES (${ table . columns . map ( ( ) => '?' ) . join ( ', ' ) } )` ) ;
138+ const query = `INSERT INTO ${ table . name } VALUES (${ table . columns . map ( ( ) => '?' ) . join ( ', ' ) } )` ;
139+ const stmt = this . database . prepare ( query ) ;
137140 for ( const record of table . records ) {
138141 stmt . run ( ...record )
139142 }
@@ -249,9 +252,14 @@ class Sqlite extends Base {
249252 . map ( table => `SELECT ${ column } FROM ${ table } ` )
250253 . join ( ' UNION ALL ' ) ;
251254
252- queries . push ( `SELECT '${ column } ', SUM(${ column } ) FROM (${ subTableQueries } )` )
255+ if ( subTableQueries . length > 0 ) {
256+ queries . push ( `SELECT '${ column } ', SUM(${ column } ) FROM (${ subTableQueries } )` ) ;
257+ }
258+ }
259+
260+ if ( queries . length > 0 ) {
261+ this . stats . set ( 'view_time_stats' , queries . join ( ' UNION ALL ' ) ) ;
253262 }
254- this . stats . set ( 'view_time_stats' , queries . join ( ' UNION ALL ' ) )
255263 }
256264
257265 makeIssues ( ) {
0 commit comments