@icgio/icg-utils 1.7.32 → 1.7.34

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.
Files changed (2) hide show
  1. package/lib/influxdb.js +20 -25
  2. package/package.json +1 -1
package/lib/influxdb.js CHANGED
@@ -15,17 +15,6 @@ function fields_check(fields) {
15
15
  return result
16
16
  }
17
17
 
18
- function check_points(points) {
19
- return points.filter((point) => {
20
- if (fields_check(point.fields) && (!point.timestamp || point.timestamp instanceof Date)) {
21
- return true
22
- } else {
23
- console.error('influx check_points', point)
24
- return false
25
- }
26
- })
27
- }
28
-
29
18
  module.exports = class Influx {
30
19
  constructor(config) {
31
20
  const { url, token, org, org_id, bucket, schema } = config
@@ -67,8 +56,17 @@ module.exports = class Influx {
67
56
  } else {
68
57
  this.bucket_exist = true
69
58
  }
70
- } else if (check_points(points)) {
71
- points = points.map((p) => {
59
+ }
60
+ points = points
61
+ .filter((point) => {
62
+ if (fields_check(point.fields) && (!point.timestamp || point.timestamp instanceof Date)) {
63
+ return true
64
+ } else {
65
+ console.error('influx check_points', point)
66
+ return false
67
+ }
68
+ })
69
+ .map((p) => {
72
70
  let p_temp = new Point(p.measurement)
73
71
  for (let tag in p.tags) {
74
72
  p_temp = p_temp.tag(tag, p.tags[tag])
@@ -86,17 +84,14 @@ module.exports = class Influx {
86
84
  }
87
85
  return p_temp
88
86
  })
89
- write_api.writePoints(points)
90
- write_api
91
- .close()
92
- .then(() => {
93
- cb({ success: true, body: points.length })
94
- })
95
- .catch((err) => {
96
- cb({ success: false, body: err })
97
- })
98
- } else {
99
- cb({ success: false, body: 'points-error' })
100
- }
87
+ write_api.writePoints(points)
88
+ write_api
89
+ .close()
90
+ .then(() => {
91
+ cb({ success: true, body: points.length })
92
+ })
93
+ .catch((err) => {
94
+ cb({ success: false, body: err })
95
+ })
101
96
  }
102
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.7.32",
3
+ "version": "1.7.34",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {