You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/thinx/influx.js
+10-6Lines changed: 10 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -75,9 +75,13 @@ module.exports = class InfluxConnector {
75
75
if(!/^[a-zA-Z0-9_]+$/.test(measurement)){
76
76
thrownewError('Invalid input');
77
77
}
78
+
79
+
if(!/^[a-zA-Z0-9_]+$/.test(owner_id)){
80
+
thrownewError('Invalid input');
81
+
}
78
82
79
-
this.influxdb.query(`SELECT mean("value") AS "mean_value" FROM "stats"."autogen"."${measurement}" WHERE "owner_id"=$owner_id`,{
80
-
bind: {
83
+
this.influxdb.query(`SELECT mean("value") AS "mean_value" FROM "stats"."autogen"."${measurement}" WHERE "owner_id"="${owner_id}"`,{
84
+
placeholders: {
81
85
owner_id: owner_id
82
86
}
83
87
}).catch(e=>{
@@ -102,8 +106,8 @@ module.exports = class InfluxConnector {
102
106
for(letmeasurementinkpis){
103
107
letkpi=kpis[measurement];
104
108
// this should be actually array of results
105
-
results[kpi]=awaitthis.influxdb.query(`SELECT mean("value") AS "mean_value" FROM "stats"."autogen"."${measurement}" WHERE "owner_id"=$owner_id AND time > ${midnight}'`,{
106
-
bind: {
109
+
results[kpi]=awaitthis.influxdb.query(`SELECT mean("value") AS "mean_value" FROM "stats"."autogen"."${measurement}" WHERE "owner_id"="${owner_id}" AND time > ${midnight}'`,{
110
+
placeholders: {
107
111
owner_id: owner_id
108
112
}
109
113
}).catch(e=>{
@@ -133,8 +137,8 @@ module.exports = class InfluxConnector {
133
137
for(letmeasurementinkpis){
134
138
letkpi=kpis[measurement];
135
139
// this should be actually array of results
136
-
results[kpi]=awaitthis.influxdb.query(`SELECT mean("value") AS "mean_value" FROM "stats"."autogen"."${kpi}" WHERE "owner_id"=$owner_id AND time > ${week_ago}'`,{
137
-
bind: {
140
+
results[kpi]=awaitthis.influxdb.query(`SELECT mean("value") AS "mean_value" FROM "stats"."autogen"."${kpi}" WHERE "owner_id"="${owner_id}" AND time > ${week_ago}'`,{
0 commit comments