0.7.38-B
This commit is contained in:
@@ -1678,6 +1678,139 @@ LIMIT ?
|
||||
}
|
||||
}
|
||||
|
||||
/// Lists samples of launch-origin attributions.
|
||||
pub async fn query_local_launch_origin_diagnostic_list_samples(
|
||||
database: &crate::Database,
|
||||
limit: i64,
|
||||
) -> Result<std::vec::Vec<crate::LocalLaunchOriginDiagnosticSampleDto>, crate::Error> {
|
||||
match database.connection() {
|
||||
crate::DatabaseConnection::Sqlite(pool) => {
|
||||
let rows_result = sqlx::query_as::<
|
||||
sqlx::Sqlite,
|
||||
crate::db::dtos::LocalLaunchOriginDiagnosticSampleRow,
|
||||
>(
|
||||
r#"
|
||||
SELECT
|
||||
la.id AS launch_attribution_id,
|
||||
ls.code AS launch_surface_code,
|
||||
ls.name AS launch_surface_name,
|
||||
ct.signature AS transaction_signature,
|
||||
la.decoded_event_id AS decoded_event_id,
|
||||
la.protocol_name AS protocol_name,
|
||||
la.match_kind AS match_kind,
|
||||
la.matched_value AS matched_value,
|
||||
la.pool_id AS pool_id,
|
||||
p.address AS pool_address,
|
||||
la.pair_id AS pair_id,
|
||||
pair.symbol AS pair_symbol
|
||||
FROM k_sol_launch_attributions la
|
||||
JOIN k_sol_launch_surfaces ls ON ls.id = la.launch_surface_id
|
||||
JOIN k_sol_chain_transactions ct ON ct.id = la.transaction_id
|
||||
LEFT JOIN k_sol_pools p ON p.id = la.pool_id
|
||||
LEFT JOIN k_sol_pairs pair ON pair.id = la.pair_id
|
||||
ORDER BY la.id DESC
|
||||
LIMIT ?
|
||||
"#,
|
||||
)
|
||||
.bind(limit)
|
||||
.fetch_all(pool)
|
||||
.await;
|
||||
let rows = match rows_result {
|
||||
Ok(rows) => rows,
|
||||
Err(error) => {
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot list launch-origin diagnostic samples on sqlite: {}",
|
||||
error
|
||||
)));
|
||||
},
|
||||
};
|
||||
let mut samples = std::vec::Vec::new();
|
||||
for row in rows {
|
||||
samples.push(crate::LocalLaunchOriginDiagnosticSampleDto {
|
||||
launch_attribution_id: row.launch_attribution_id,
|
||||
launch_surface_code: row.launch_surface_code,
|
||||
launch_surface_name: row.launch_surface_name,
|
||||
transaction_signature: row.transaction_signature,
|
||||
decoded_event_id: row.decoded_event_id,
|
||||
protocol_name: row.protocol_name,
|
||||
match_kind: row.match_kind,
|
||||
matched_value: row.matched_value,
|
||||
pool_id: row.pool_id,
|
||||
pool_address: row.pool_address,
|
||||
pair_id: row.pair_id,
|
||||
pair_symbol: row.pair_symbol,
|
||||
});
|
||||
}
|
||||
return Ok(samples);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Lists samples of pool-origin rows and their optional launch linkage.
|
||||
pub async fn query_local_pool_origin_diagnostic_list_samples(
|
||||
database: &crate::Database,
|
||||
limit: i64,
|
||||
) -> Result<std::vec::Vec<crate::LocalPoolOriginDiagnosticSampleDto>, crate::Error> {
|
||||
match database.connection() {
|
||||
crate::DatabaseConnection::Sqlite(pool) => {
|
||||
let rows_result = sqlx::query_as::<
|
||||
sqlx::Sqlite,
|
||||
crate::db::dtos::LocalPoolOriginDiagnosticSampleRow,
|
||||
>(
|
||||
r#"
|
||||
SELECT
|
||||
po.id AS pool_origin_id,
|
||||
d.code AS dex_code,
|
||||
po.pool_id AS pool_id,
|
||||
p.address AS pool_address,
|
||||
po.pair_id AS pair_id,
|
||||
pair.symbol AS pair_symbol,
|
||||
ls.code AS launch_surface_code,
|
||||
po.founding_signature AS founding_signature,
|
||||
po.founding_protocol_name AS founding_protocol_name,
|
||||
po.founding_event_kind AS founding_event_kind
|
||||
FROM k_sol_pool_origins po
|
||||
JOIN k_sol_dexes d ON d.id = po.dex_id
|
||||
JOIN k_sol_pools p ON p.id = po.pool_id
|
||||
LEFT JOIN k_sol_pairs pair ON pair.id = po.pair_id
|
||||
LEFT JOIN k_sol_launch_attributions la ON la.id = po.launch_attribution_id
|
||||
LEFT JOIN k_sol_launch_surfaces ls ON ls.id = la.launch_surface_id
|
||||
ORDER BY po.id DESC
|
||||
LIMIT ?
|
||||
"#,
|
||||
)
|
||||
.bind(limit)
|
||||
.fetch_all(pool)
|
||||
.await;
|
||||
let rows = match rows_result {
|
||||
Ok(rows) => rows,
|
||||
Err(error) => {
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot list pool-origin diagnostic samples on sqlite: {}",
|
||||
error
|
||||
)));
|
||||
},
|
||||
};
|
||||
let mut samples = std::vec::Vec::new();
|
||||
for row in rows {
|
||||
samples.push(crate::LocalPoolOriginDiagnosticSampleDto {
|
||||
pool_origin_id: row.pool_origin_id,
|
||||
dex_code: row.dex_code,
|
||||
pool_id: row.pool_id,
|
||||
pool_address: row.pool_address,
|
||||
pair_id: row.pair_id,
|
||||
pair_symbol: row.pair_symbol,
|
||||
launch_surface_code: row.launch_surface_code,
|
||||
founding_signature: row.founding_signature,
|
||||
founding_protocol_name: row.founding_protocol_name,
|
||||
founding_event_kind: row.founding_event_kind,
|
||||
});
|
||||
}
|
||||
return Ok(samples);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Lists prioritized samples of tokens whose metadata is still incomplete.
|
||||
pub async fn query_local_token_metadata_gap_diagnostic_list_samples(
|
||||
database: &crate::Database,
|
||||
|
||||
Reference in New Issue
Block a user