Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
caparker committed Oct 31, 2024
1 parent d9ee861 commit ecb79b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fetcher/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function checkResponseData(data, start_timestamp, end_timestamp) {
}

const fetchFileLocal = async (file) => {
const filepath = file.path;
const filepath = file.path.replace('$CWD', process.cwd());
const data = [];
console.debug('fetching file', filepath);
return new Promise((resolve, reject) => {
Expand Down
15 changes: 12 additions & 3 deletions fetcher/providers/generic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Providers = require('../lib/providers');
const { fetchFile, DRYRUN } = require('../lib/utils');
const { fetchFile, DRYRUN, VERBOSE } = require('../lib/utils');
const { Measures, FixedMeasure } = require('../lib/measure');
const { Measurand } = require('../lib/measurand');
const dayjs = require('dayjs');
Expand Down Expand Up @@ -287,7 +287,7 @@ class Client {
this.manufacturer_key = source.meta.manufacturer_key || 'manufacturer_name';
this.model_key = source.meta.model_key || 'model_name';
this.datetime_key = source.meta.timestamp_key || 'datetime';
this.datetime_format = 'YYYY-MM-DD HH-mm-ss';
this.datetime_format =source.meta.datetime_format || 'YYYY-MM-DD HH-mm-ss';

Check failure on line 290 in fetcher/providers/generic.js

View workflow job for this annotation

GitHub Actions / build

Operator '=' must be spaced
this.timezone = source.meta.timezone || 'UTC';
this.datasources = {};
this.missing_datasources = [];
Expand Down Expand Up @@ -434,7 +434,15 @@ class Client {
* @returns {string} - formated timestamp string
*/
getDatetime (row) {
return dayjs.utc(row[this.datetime_key], this.datetime_format);
const dt_string = row[this.datetime_key];
if(!dt_string) {

Check failure on line 438 in fetcher/providers/generic.js

View workflow job for this annotation

GitHub Actions / build

Expected space(s) after "if"
throw new Error(`Missing date/time field. Looking in ${this.datetime_key}`);
}
const dt = dayjs.utc(dt_string, this.datetime_format);
if(!dt.isValid()) {

Check failure on line 442 in fetcher/providers/generic.js

View workflow job for this annotation

GitHub Actions / build

Expected space(s) after "if"
throw new Error(`A valid date could not be made from ${dt_string} using ${this.datetime_format}`);
}
return dt;
}

/**
Expand All @@ -458,6 +466,7 @@ class Client {
// if strict than throw error, otherwise just log for later
if(!this.log[type]) this.log[type] = [];

Check failure on line 467 in fetcher/providers/generic.js

View workflow job for this annotation

GitHub Actions / build

Expected space(s) after "if"
this.log[type].push({ message, err});

Check failure on line 468 in fetcher/providers/generic.js

View workflow job for this annotation

GitHub Actions / build

A space is required before '}'
if (VERBOSE) console.log(`${type}:`, err && err.message);
}

/**
Expand Down

0 comments on commit ecb79b7

Please sign in to comment.