Skip to content

Commit 8a914b6

Browse files
committed
Linting
1 parent 9a8f2b4 commit 8a914b6

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

app/controllers/csv.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const debug = require('debug')('tutorial:csv');
55
const _ = require('lodash');
66
const Status = require('http-status-codes');
77
const path = require('path');
8-
const moment = require('moment-timezone');
98

109
/*
1110
* Delete the temporary file
@@ -40,30 +39,19 @@ function readCsvFile(path) {
4039
});
4140
}
4241

43-
/*
44-
* Strip the id and an key from the header row.
45-
*/
46-
function parseId(input) {
47-
const regexId = /^[^\s]+/;
48-
const regexKey = /[\w]+$/;
49-
const id = regexId.exec(input)[0];
50-
const key = regexKey.exec(input)[0];
5142

52-
return { id, key };
53-
}
5443

5544
function createEntitiesFromRows(rows) {
5645
const allEntities = [];
5746
const timestamp = new Date().toISOString();
5847

5948
rows.forEach((row) => {
60-
const timestamp = moment.tz(row.annee, 'Etc/UTC').toISOString();
6149
const entity = {
6250
id: row.id,
6351
type: row.type
6452
};
6553

66-
Object.keys(row).forEach((key, index) => {
54+
Object.keys(row).forEach((key) => {
6755
const value = row[key];
6856
if (value !== '') {
6957
switch (key) {
@@ -74,7 +62,7 @@ function createEntitiesFromRows(rows) {
7462
case 'legalId':
7563
case 'name':
7664
case 'species':
77-
entity[key] = { value: value, type: 'Property' };
65+
entity[key] = { value, type: 'Property' };
7866
break;
7967

8068
case 'temperature':
@@ -154,6 +142,8 @@ function createEntitiesFromRows(rows) {
154142
break;
155143
case 'id':
156144
case 'type':
145+
case 'lat':
146+
case 'lng':
157147
break;
158148
default:
159149
debug('unknown : ' + key);
@@ -200,7 +190,7 @@ const upload = (req, res) => {
200190
.then((entities) => {
201191
//console.log(JSON.stringify(entities[0], null, 2))
202192

203-
batchEntities = [];
193+
const batchEntities = [];
204194
const chunkSize = 10;
205195

206196
for (let i = 0; i < entities.length; i += chunkSize) {
@@ -213,6 +203,7 @@ const upload = (req, res) => {
213203
.then(async (promises) => {
214204
const results = [];
215205
for (const promise of promises) {
206+
// eslint-disable-next-line no-await-in-loop
216207
const result = await promise;
217208
results.push(result);
218209
}

app/lib/batchUpdate.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const CONTEXT_BROKER_URL = process.env.CONTEXT_BROKER || 'http://localhost:1026/ngsi-ld/v1';
2-
const LINKED_DATA = process.env.IOTA_JSON_LD_CONTEXT || config.contextBroker.jsonLdContext;
2+
const LINKED_DATA = process.env.IOTA_JSON_LD_CONTEXT || 'http://context/ngsi-context.jsonld';
3+
const debug = require('debug')('tutorial:batchUpdate');
34

45
async function parse(response) {
56
let text = '';
@@ -17,7 +18,7 @@ function is2xxSuccessful(status) {
1718
}
1819

1920
// measures sent over HTTP are POST requests with params
20-
async function sendAsHTTP(state) {
21+
function sendAsHTTP(state) {
2122
const url = CONTEXT_BROKER_URL + '/entityOperations/upsert';
2223
const headers = {
2324
'Content-Type': 'application/json',
@@ -38,7 +39,7 @@ async function sendAsHTTP(state) {
3839
return data.body;
3940
});
4041
} catch (e) {
41-
console.log(e);
42+
debug(e);
4243
return null;
4344
}
4445
}

0 commit comments

Comments
 (0)