parent
b1e88ff261
commit
5d4b525743
1 changed files with 21 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ use crate::{db::DB, timeutil::time_now};
|
|||
pub struct ContractCount {
|
||||
active: u64,
|
||||
ended: u64,
|
||||
interactions: u64,
|
||||
}
|
||||
|
||||
fn db_contract_count_all(db: &Connection) -> Result<ContractCount> {
|
||||
|
|
@ -31,7 +32,15 @@ fn db_contract_count_all(db: &Connection) -> Result<ContractCount> {
|
|||
|row| row.get(0),
|
||||
)?;
|
||||
|
||||
Ok(ContractCount { active, ended })
|
||||
let interactions: u64 = db.query_row("SELECT COUNT(*) FROM pool_history_entry", [], |row| {
|
||||
row.get(0)
|
||||
})?;
|
||||
|
||||
Ok(ContractCount {
|
||||
active,
|
||||
ended,
|
||||
interactions,
|
||||
})
|
||||
}
|
||||
|
||||
fn db_contract_count_by_token(db: &Connection, token_id: &str) -> Result<ContractCount> {
|
||||
|
|
@ -47,7 +56,17 @@ fn db_contract_count_by_token(db: &Connection, token_id: &str) -> Result<Contrac
|
|||
|row| row.get(0),
|
||||
)?;
|
||||
|
||||
Ok(ContractCount { active, ended })
|
||||
let interactions: u64 = db.query_row(
|
||||
"SELECT COUNT(*) FROM pool_history_entry phe JOIN pool p ON phe.pool = p.creation_utxo WHERE p.token_id = ?",
|
||||
[token_id],
|
||||
|row| row.get(0),
|
||||
)?;
|
||||
|
||||
Ok(ContractCount {
|
||||
active,
|
||||
ended,
|
||||
interactions,
|
||||
})
|
||||
}
|
||||
|
||||
#[get("/contract/count")]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue