Skip to content

Commit

Permalink
Added log message to the other providers
Browse files Browse the repository at this point in the history
  • Loading branch information
caparker committed Feb 29, 2024
1 parent 0005e31 commit c01a7e9
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 14 deletions.
5 changes: 4 additions & 1 deletion fetcher/lib/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class Providers {
if(VERBOSE) console.log('Starting processor', { ...source, ...config });
const log = await this[source.provider].processor({ ...source, ...config });
// source_name is more consistent with our db schema
log.source_name = source.provider;
if(typeof(log) == 'object' && !Array.isArray(log) && !log.source_name) {
log.source_name = source.provider;
}
return(log);
}

Expand All @@ -56,6 +58,7 @@ class Providers {
* @param {String} subject
*/
async publish(message, subject) {
console.log('Publishing:', subject, message);
if(process.env.TOPIC_ARN) {
const cmd = new PublishCommand({
TopicArn: process.env.TOPIC_ARN,
Expand Down
5 changes: 3 additions & 2 deletions fetcher/providers/clarity.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/

const dayjs = require('dayjs');
//const pLimit = require('p-limit');
const { default: pLimit } = import('p-limit');
const pLimit = require('p-limit');

const Providers = require('../lib/providers');
const { VERBOSE, request } = require('../lib/utils');
Expand Down Expand Up @@ -275,6 +274,8 @@ class ClarityApi {
...stations,
Providers.put_measures(this.source.provider, measures)
]);
const source_name = `${this.source.provider}-${this.org.orgId}`;
return { source_name, locations: stations.length, measures: measures.length, from: measures.from, to: measures.to };
}
}

Expand Down
3 changes: 1 addition & 2 deletions fetcher/providers/cmu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ const dayjs = require('dayjs')
.extend(require('dayjs/plugin/utc'))
.extend(require('dayjs/plugin/timezone'))
.extend(require('dayjs/plugin/customParseFormat'));
//const pLimit = require('p-limit');
const { default: pLimit } = import('p-limit');
const pLimit = require('p-limit');
const Providers = require('../lib/providers');
const { Sensor, SensorNode, SensorSystem } = require('../lib/station');
const { Measures, FixedMeasure } = require('../lib/measure');
Expand Down
1 change: 1 addition & 0 deletions fetcher/providers/purpleair.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ async function processor(source) {

await Providers.put_measures(source.provider, measures);
if (VERBOSE) console.log(`ok - all ${measures.length} measurements pushed`);
return { locations: stations.length, measures: measures.length, from: measures.from, to: measures.to };
}

async function fetchSensorData(source) {
Expand Down
1 change: 1 addition & 0 deletions fetcher/providers/senstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ async function processor(source) {

await Providers.put_measures(source.provider, measures, `senstate-${Math.floor(Date.now() / 1000)}-${Math.random().toString(36).substring(8)}`);
console.log(`ok - all ${measures.length} measurements pushed`);
return { locations: stations.length, measures: measures.length, from: measures.from, to: measures.to };
}


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"dotenv": "^16.4.5",
"geo-tz": "^8.0.1",
"googleapis": "133",
"p-limit": "^5.0.0",
"p-limit": "3.1.0",
"request": "^2.88.2"
},
"devDependencies": {
Expand Down
9 changes: 1 addition & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4725,7 +4725,7 @@ optionator@^0.9.3:
prelude-ls "^1.2.1"
type-check "^0.4.0"

p-limit@^3.0.2:
p-limit@^3.0.2, [email protected]:
version "3.1.0"
resolved "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz"
integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==
Expand All @@ -4739,13 +4739,6 @@ p-limit@^4.0.0:
dependencies:
yocto-queue "^1.0.0"

p-limit@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/p-limit/-/p-limit-5.0.0.tgz"
integrity sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==
dependencies:
yocto-queue "^1.0.0"

p-locate@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz"
Expand Down

0 comments on commit c01a7e9

Please sign in to comment.