pow stats for solution and verification

This commit is contained in:
realaravinth
2021-05-09 19:33:28 +05:30
parent 7792d5ccc7
commit 527724ecda
7 changed files with 57 additions and 5 deletions

View File

@@ -17,7 +17,9 @@
use sqlx::PgPool;
pub async fn fetched(key: &str, db: &PgPool) {
/// record PoWConfig fetches
#[inline]
pub async fn record_fetch(key: &str, db: &PgPool) {
let _ = sqlx::query!(
"INSERT INTO mcaptcha_pow_fetched_stats
(config_id) VALUES ((SELECT config_id FROM mcaptcha_config WHERE key = $1))",
@@ -26,3 +28,27 @@ pub async fn fetched(key: &str, db: &PgPool) {
.execute(db)
.await;
}
/// record PoWConfig solves
#[inline]
pub async fn record_solve(key: &str, db: &PgPool) {
let _ = sqlx::query!(
"INSERT INTO mcaptcha_pow_solved_stats
(config_id) VALUES ((SELECT config_id FROM mcaptcha_config WHERE key = $1))",
&key,
)
.execute(db)
.await;
}
/// record PoWConfig confirms
#[inline]
pub async fn record_confirm(key: &str, db: &PgPool) {
let _ = sqlx::query!(
"INSERT INTO mcaptcha_pow_confirmed_stats
(config_id) VALUES ((SELECT config_id FROM mcaptcha_config WHERE key = $1))",
&key,
)
.execute(db)
.await;
}