Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
russbiggs committed Jul 13, 2023
1 parent 1336c6c commit d59e063
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
82 changes: 41 additions & 41 deletions fetcher/providers/clarity.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ class ClarityApi {
let ds = response.body;

if (process.env.SOURCEID) {
ds = ds.filter((d) => d.deviceCode === process.env.SOURCEID);
ds = ds.filter((d) => d.deviceCode === process.env.SOURCEID);
} else {
ds = ds.filter(d=>d.sourceType == 'CLARITY_NODE');
ds = ds.filter((d)=>d.sourceType === 'CLARITY_NODE');
}

if (VERBOSE) {
console.debug(`-------------------\nListing ${ds.length} sources for ${this.org.organizationName}`);
console.debug(`-------------------\nListing ${ds.length} sources for ${this.org.organizationName}`);
ds.map((d) => console.log(`${d.sourceType}: (${d.subscriptionStatus}) ${d.deviceCode} - ${d.name}`));
}
return ds;
Expand All @@ -79,12 +79,12 @@ class ClarityApi {
*
* @returns {Promise<Device[]>}
*/
listDevices() {
return request({
json: true,
method: 'GET',
headers: { 'X-API-Key': this.apiKey },
url: new URL('v2/devices/nodes', this.baseUrl),
listDevices() {
return request({
json: true,
method: 'GET',
headers: { 'X-API-Key': this.apiKey },
url: new URL('v2/devices/nodes', this.baseUrl),
qs: { 'org': this.orgId }
}).then((response) => response.body).then((response) => {
if (process.env.SOURCEID) {
Expand All @@ -95,7 +95,7 @@ class ClarityApi {
}
const working = response.filter((o) => o.lifeStage.stage === 'working');
if (VERBOSE) {
console.debug(`-----------------\nListing devices for ${this.org.organizationName}\nFound ${response.length} total devices, ${working.length} working`);
console.debug(`-----------------\nListing devices for ${this.org.organizationName}\nFound ${response.length} total devices, ${working.length} working`);
response
.filter((d) => d.lifeStage.stage !== 'working')
.map((d) => console.log(`DEVICE: ${d.nodeId} - ${d.model} - ${d.lifeStage.stage}`));
Expand Down Expand Up @@ -152,11 +152,11 @@ class ClarityApi {
while (true) {
url.searchParams.set('skip', offset);
if (VERBOSE) console.log(`Fetching ${url}&key=${this.apiKey}`);
const response = await request({
url,
const response = await request({
url,
json: true,
method: 'GET',
headers: { 'X-API-Key': this.apiKey, 'Accept-Encoding': 'gzip' },
headers: { 'X-API-Key': this.apiKey, 'Accept-Encoding': 'gzip' },
gzip: true
});

Expand Down Expand Up @@ -196,42 +196,42 @@ class ClarityApi {
*/
async sync(supportedMeasurands, since) {
// get all the devices, even if expired
let devices = await this.listAugmentedDevices();

if (VERBOSE) {
console.debug(`-----------------------\n Syncing ${this.source.provider}/${this.org.organizationName}`, devices.length);
devices.map( d => {
if(d.pairedAccessoryModules.length>0) {
console.debug(`--------------------\n Found device with ${d.length} modules`);
}
});
}
let devices = await this.listAugmentedDevices();

if (VERBOSE) {
console.debug(`-----------------------\n Syncing ${this.source.provider}/${this.org.organizationName}`, devices.length);
devices.map( (d) => {
if (d.pairedAccessoryModules.length > 0) {
console.debug(`--------------------\n Found device with ${d.length} modules`);
}
});
}
// Create one station per device
const stations = devices.map((device) =>
Providers.put_station(
this.source.provider,
new SensorNode({
sensor_node_id: `${this.org.organizationName}-${device.nodeId}`,
sensor_node_site_name: device.name || device.nodeId, // fall back to code when missing name
sensor_node_geometry: device.location.coordinates,
sensor_node_status: device.subscriptionStatus,
sensor_node_source_name: this.source.provider, //
sensor_node_site_description: this.org.organizationName,
sensor_node_ismobile: false, // should remove this and just use instrument
//sensor_node_instrument: device.model,
new SensorNode({
sensor_node_id: `${this.org.organizationName}-${device.nodeId}`,
sensor_node_site_name: device.name || device.nodeId, // fall back to code when missing name
sensor_node_geometry: device.location.coordinates,
sensor_node_status: device.subscriptionStatus,
sensor_node_source_name: this.source.provider, //
sensor_node_site_description: this.org.organizationName,
sensor_node_ismobile: false, // should remove this and just use instrument
// sensor_node_instrument: device.model,
sensor_node_deployed_date: device.lifeStage.when,
sensor_system: new SensorSystem({
sensor_system_manufacturer_name: this.source.provider,
// Create one sensor per characteristic
sensors: [] //Object.values(supportedMeasurands)
.map(
(measurand) =>
new Sensor({
sensor_id: getSensorId(device, measurand),
measurand_parameter: measurand.parameter,
measurand_unit: measurand.normalized_unit
})
)
sensors: [] // Object.values(supportedMeasurands)
.map(
(measurand) =>
new Sensor({
sensor_id: getSensorId(device, measurand),
measurand_parameter: measurand.parameter,
measurand_unit: measurand.normalized_unit
})
)
})
})
)
Expand Down
2 changes: 1 addition & 1 deletion fetcher/providers/habitatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async function process_mobile_locations(source_name, source, measurands) {

async function fixed_locations(source) {
const params = {
time_from: String(Math.round(Date.now() / 1000) - 60 * 2), // 60s * 2min
time_from: String(Math.round(Date.now() / 1000) - 60 * 2), // 60s * 2min
time_to: String(Math.round(Date.now() / 1000)),
tags: '',
usernames: '',
Expand Down

0 comments on commit d59e063

Please sign in to comment.