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
where_clauses.push(format!("events->'{}'->'{}'->'{}' IS NOT NULL", query.event_type, query.metric, session.uid));
120
-
format!("select SUM((events->'{}'->'{}'->>'{}')::numeric) as value, extract({} from created) as time from event_aggregates", query.event_type, query.metric, session.uid, interval)
130
+
where_clauses.push(format!(
131
+
"events->'{}'->'{}'->'{}' IS NOT NULL",
132
+
query.event_type, query.metric, session.uid
133
+
));
134
+
format!(
135
+
"select SUM((events->'{}'->'{}'->>'{}')::numeric) as value, extract({} from created) as time from event_aggregates",
where_clauses.push(format!("events->'{}'->'{}' IS NOT NULL", query.event_type, query.metric));
124
-
format!("select SUM(value::numeric)::varchar as value, extract({} from created) as time from event_aggregates, jsonb_each_text(events->'{}'->'{}')", interval, query.event_type, query.metric)
140
+
where_clauses.push(format!(
141
+
"events->'{}'->'{}' IS NOT NULL",
142
+
query.event_type, query.metric
143
+
));
144
+
format!(
145
+
"select SUM(value::numeric)::varchar as value, extract({} from created) as time from event_aggregates, jsonb_each_text(events->'{}'->'{}')",
146
+
interval, query.event_type, query.metric
147
+
)
125
148
}
126
149
};
127
150
128
-
let sql_query = format!("{} WHERE {} GROUP BY time LIMIT {}", select_query, where_clauses.join(" AND "), applied_limit);
151
+
let sql_query = format!(
152
+
"{} WHERE {} GROUP BY time LIMIT {}",
153
+
select_query,
154
+
where_clauses.join(" AND "),
155
+
applied_limit
156
+
);
129
157
130
158
// log the query here
131
159
println!("{}", sql_query);
132
160
133
161
// execute query
134
-
let result = app.pool
162
+
let result = app
163
+
.pool
135
164
.run(move |connection| {
136
165
asyncmove{
137
166
match connection.prepare(&sql_query).await{
138
167
Ok(stmt) => match connection.query(&stmt,&[]).await{
139
168
Ok(rows) => {
140
-
let analytics:Vec<AnalyticsResponse> = rows.iter().map(AnalyticsResponse::from).collect();
0 commit comments