@icgio/icg-utils 1.7.28 → 1.7.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/influxdb.js CHANGED
@@ -1,5 +1,7 @@
1
1
  const _ = require('lodash')
2
2
 
3
+ const { parse } = require('csv-parse')
4
+
3
5
  const { InfluxDB, Point } = require('@influxdata/influxdb-client')
4
6
  const { BucketsAPI } = require('@influxdata/influxdb-client-apis')
5
7
 
@@ -35,21 +37,25 @@ module.exports = class Influx {
35
37
  this.bucket_exist = false
36
38
  this.schema = schema
37
39
  }
38
- // query(query_string, cb) {
39
- // this.query_api = this.influx_db.getQueryApi(org)
40
- // this.db
41
- // .query(query_string)
42
- // .then((res) => {
43
- // res.map((e) => {
44
- // e.date = new Date(e.time.toNanoISOString())
45
- // return e
46
- // })
47
- // cb({ success: true, body: res })
48
- // })
49
- // .catch((err) => {
50
- // cb({ success: false, error: err })
51
- // })
52
- // }
40
+ async query(query_string, cb) {
41
+ const query_api = this.influx_db.getQueryApi(this.org)
42
+ let result = await query_api.queryRaw(query_string)
43
+ let temp = parse(
44
+ result,
45
+ {
46
+ columns: true,
47
+ comment: '#',
48
+ skip_empty_lines: true,
49
+ },
50
+ (err, res) => {
51
+ if (!err) {
52
+ cb({ success: true, body: res })
53
+ } else {
54
+ cb({ success: false, body: err })
55
+ }
56
+ }
57
+ )
58
+ }
53
59
  async write_points_with_check(points, cb) {
54
60
  const write_api = this.influx_db.getWriteApi(this.org, this.bucket)
55
61
  if (!this.bucket_exist) {
@@ -84,10 +90,10 @@ module.exports = class Influx {
84
90
  cb({ success: true, body: points.length })
85
91
  })
86
92
  .catch((err) => {
87
- cb({ success: false, error: err })
93
+ cb({ success: false, body: err })
88
94
  })
89
95
  } else {
90
- cb({ success: false, error: 'points-error' })
96
+ cb({ success: false, body: 'points-error' })
91
97
  }
92
98
  }
93
99
  }
package/lib/logger.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const winston = require('winston')
2
- const Papertrail = require('winston-papertrail').Papertrail
2
+ // const Papertrail = require('winston-papertrail').Papertrail
3
3
 
4
4
  let logger = new winston.Logger({
5
5
  levels: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.7.28",
3
+ "version": "1.7.29",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -22,17 +22,15 @@
22
22
  "dependencies": {
23
23
  "@influxdata/influxdb-client": "^1.33.0",
24
24
  "@influxdata/influxdb-client-apis": "^1.33.0",
25
- "etherscan-api": "^8.1.5",
25
+ "csv-parse": "^5.3.3",
26
26
  "external-ip": "^2.3.1",
27
27
  "htmlparser2": "^3.10.1",
28
- "influx": "^5.9.3",
29
28
  "lodash": "^4.17.21",
30
29
  "mailgun-js": "^0.18.1",
31
30
  "needle": "^3.2.0",
32
31
  "nodemailer": "^4.7.0",
33
32
  "qrcode-terminal": "^0.12.0",
34
33
  "websocket": "^1.0.33",
35
- "winston": "^2.4.5",
36
- "winston-papertrail": "^1.0.5"
34
+ "winston": "^2.4.5"
37
35
  }
38
36
  }