Skip to content

Commit a827ec9

Browse files
committed
revert bind to placeholders
1 parent 1573cb9 commit a827ec9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/thinx/influx.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ module.exports = class InfluxConnector {
7575
if (!/^[a-zA-Z0-9_]+$/.test(measurement)) {
7676
throw new Error('Invalid input');
7777
}
78+
79+
if (!/^[a-zA-Z0-9_]+$/.test(owner_id)) {
80+
throw new Error('Invalid input');
81+
}
7882

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: {
8185
owner_id: owner_id
8286
}
8387
}).catch(e => {
@@ -102,8 +106,8 @@ module.exports = class InfluxConnector {
102106
for (let measurement in kpis) {
103107
let kpi = kpis[measurement];
104108
// this should be actually array of results
105-
results[kpi] = await this.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] = await this.influxdb.query(`SELECT mean("value") AS "mean_value" FROM "stats"."autogen"."${measurement}" WHERE "owner_id"="${owner_id}" AND time > ${midnight}'`, {
110+
placeholders: {
107111
owner_id: owner_id
108112
}
109113
}).catch(e => {
@@ -133,8 +137,8 @@ module.exports = class InfluxConnector {
133137
for (let measurement in kpis) {
134138
let kpi = kpis[measurement];
135139
// this should be actually array of results
136-
results[kpi] = await this.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] = await this.influxdb.query(`SELECT mean("value") AS "mean_value" FROM "stats"."autogen"."${kpi}" WHERE "owner_id"="${owner_id}" AND time > ${week_ago}'`, {
141+
placeholders: {
138142
owner_id: owner_id
139143
}
140144
}).catch((e) => {

0 commit comments

Comments
 (0)