Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Rename label_group table for more consistency and clean up code
  • Loading branch information
fabianhauser committed Mar 25, 2019
commit 387ba7dce83eb7617e1169f5a291411eb37cf5ea
18 changes: 13 additions & 5 deletions src/output/sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TABLE_ISSUES = 'issues';
const TABLE_MERGE_REQUESTS = 'merge_requests';
const TABLE_TIMES = 'times';
const TABLE_LABELS = 'labels';
const TABLE_LABEL_GROUP = 'label_group';
const TABLE_LABEL_GROUP = 'label_groups';
const TABLE_MILESTONES = 'milestones';

const COLUMNS = {
Expand Down Expand Up @@ -83,7 +83,9 @@ class Table {
}
}


/**
* Promise-based abstraction of the SQLite database driver
*/
class SqliteDatabaseAbstraction {

constructor(file) {
Expand Down Expand Up @@ -133,7 +135,8 @@ class SqliteDatabaseAbstraction {
*/
insertRecords(table) {
return new Promise((resolve, reject) => {
const stmt = this.database.prepare(`INSERT INTO ${table.name} VALUES (${table.columns.map(() => '?').join(', ')})`);
const query = `INSERT INTO ${table.name} VALUES (${table.columns.map(() => '?').join(', ')})`;
const stmt = this.database.prepare(query);
for (const record of table.records) {
stmt.run(...record)
}
Expand Down Expand Up @@ -249,9 +252,14 @@ class Sqlite extends Base {
.map(table => `SELECT ${column} FROM ${table}`)
.join(' UNION ALL ');

queries.push(`SELECT '${column}', SUM(${column}) FROM (${subTableQueries})`)
if(subTableQueries.length > 0) {
queries.push(`SELECT '${column}', SUM(${column}) FROM (${subTableQueries})`);
}
}

if(queries.length > 0) {
this.stats.set('view_time_stats', queries.join(' UNION ALL '));
}
this.stats.set('view_time_stats', queries.join(' UNION ALL '))
}

makeIssues() {
Expand Down