Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 387ba7d

Browse files
committed
Rename label_group table for more consistency and clean up code
1 parent 93bcd75 commit 387ba7d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/output/sqlite.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const TABLE_ISSUES = 'issues';
1414
const TABLE_MERGE_REQUESTS = 'merge_requests';
1515
const TABLE_TIMES = 'times';
1616
const TABLE_LABELS = 'labels';
17-
const TABLE_LABEL_GROUP = 'label_group';
17+
const TABLE_LABEL_GROUP = 'label_groups';
1818
const TABLE_MILESTONES = 'milestones';
1919

2020
const COLUMNS = {
@@ -83,7 +83,9 @@ class Table {
8383
}
8484
}
8585

86-
86+
/**
87+
* Promise-based abstraction of the SQLite database driver
88+
*/
8789
class 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

Comments
 (0)