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