We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fa49d84 commit 3540400Copy full SHA for 3540400
src/graphql/queries/member_queries.rs
@@ -165,6 +165,29 @@ impl StatusInfo {
165
Ok(result)
166
}
167
168
+ async fn consecutive_misses(&self, ctx: &Context<'_>) -> Result<Option<i64>> {
169
+ let pool = ctx.data::<Arc<PgPool>>().expect("Pool must be in context.");
170
+
171
+ let result: Option<i64> = sqlx::query_scalar(
172
+ "
173
+ SELECT distance
174
+ FROM (
175
+ SELECT is_sent, ROW_NUMBER() OVER (ORDER BY date DESC) - 1 AS distance
176
+ FROM StatusUpdateHistory
177
+ WHERE member_id = $1
178
+ )
179
+ WHERE is_sent = TRUE
180
+ ORDER BY distance ASC
181
+ LIMIT 1;
182
+ ",
183
184
+ .bind(self.member_id)
185
+ .fetch_optional(pool.as_ref())
186
+ .await?;
187
188
+ Ok(result)
189
+ }
190
191
async fn update_count(
192
&self,
193
ctx: &Context<'_>,
0 commit comments