Update database detection.

This commit is contained in:
Mike Cao 2020-08-30 00:02:03 -07:00
parent 07cc61f5c3
commit 7a81dda7b6
3 changed files with 6 additions and 3 deletions

View File

@ -95,7 +95,6 @@ export function getDateArray(data, startDate, endDate, unit) {
const arr = [];
const [diff, add, normalize] = dateFuncs[unit];
const n = diff(endDate, startDate) + 1;
console.log({ startDate, endDate, n });
function findData(t) {
const x = data.find(e => {

View File

@ -22,7 +22,10 @@ const POSTGRESQL_DATE_FORMATS = {
};
export function getDatabase() {
return process.env.DATABASE_TYPE || process.env.DATABASE_URL.split(':')[0];
return (
process.env.DATABASE_TYPE ||
(process.env.DATABASE_URL && process.env.DATABASE_URL.split(':')[0])
);
}
export function getDateQuery(db, field, unit, timezone) {

View File

@ -2,7 +2,8 @@ require('dotenv').config();
const fs = require('fs');
const path = require('path');
const databaseType = process.env.DATABASE_TYPE || process.env.DATABASE_URL.split(':')[0];
const databaseType =
process.env.DATABASE_TYPE || (process.env.DATABASE_URL && process.env.DATABASE_URL.split(':')[0]);
if (!databaseType) {
throw new Error('Database schema not specified');