mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
feat: define db method to get all psuedo IDs with pagination
This commit is contained in:
@@ -289,6 +289,9 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get all psuedo IDs
|
||||
async fn analytics_get_all_psuedo_ids(&self, page: usize) -> DBResult<Vec<String>>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq)]
|
||||
|
||||
@@ -258,6 +258,12 @@ pub async fn database_works<'a, T: MCDatabase>(
|
||||
.analytics_get_psuedo_id_from_capmaign_id(c.key)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
vec![psuedo_id.clone()],
|
||||
db.analytics_get_all_psuedo_ids(0).await.unwrap()
|
||||
);
|
||||
assert!(db.analytics_get_all_psuedo_ids(1).await.unwrap().is_empty());
|
||||
|
||||
db.analytics_create_psuedo_id_if_not_exists(c.key)
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -267,6 +273,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
||||
.await
|
||||
.unwrap()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
c.key,
|
||||
db.analytics_get_capmaign_id_from_psuedo_id(&psuedo_id)
|
||||
|
||||
Reference in New Issue
Block a user