0.7.42
This commit is contained in:
@@ -89,6 +89,45 @@ LIMIT 1
|
||||
}
|
||||
}
|
||||
|
||||
/// Deletes one decoded DEX event row by its natural key.
|
||||
pub async fn query_dex_decoded_events_delete_by_key(
|
||||
database: &crate::Database,
|
||||
transaction_id: i64,
|
||||
instruction_id: std::option::Option<i64>,
|
||||
event_kind: &str,
|
||||
) -> Result<u64, crate::Error> {
|
||||
match database.connection() {
|
||||
crate::DatabaseConnection::Sqlite(pool) => {
|
||||
let query_result = sqlx::query(
|
||||
r#"
|
||||
DELETE FROM k_sol_dex_decoded_events
|
||||
WHERE transaction_id = ?
|
||||
AND (
|
||||
(instruction_id IS NULL AND ? IS NULL)
|
||||
OR instruction_id = ?
|
||||
)
|
||||
AND event_kind = ?
|
||||
"#,
|
||||
)
|
||||
.bind(transaction_id)
|
||||
.bind(instruction_id)
|
||||
.bind(instruction_id)
|
||||
.bind(event_kind)
|
||||
.execute(pool)
|
||||
.await;
|
||||
match query_result {
|
||||
Ok(result) => return Ok(result.rows_affected()),
|
||||
Err(error) => {
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot delete k_sol_dex_decoded_events by key on sqlite: {}",
|
||||
error
|
||||
)));
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads one decoded DEX event by its natural key.
|
||||
pub async fn query_dex_decoded_events_get_by_key(
|
||||
database: &crate::Database,
|
||||
|
||||
@@ -584,14 +584,11 @@ ORDER BY dex_code
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Lists observed Raydium program instruction diagnostics.
|
||||
pub async fn query_local_raydium_program_instruction_diagnostic_list_summaries(
|
||||
database: &crate::Database,
|
||||
) -> Result<
|
||||
std::vec::Vec<crate::LocalRaydiumProgramInstructionDiagnosticSummaryDto>,
|
||||
crate::Error,
|
||||
> {
|
||||
) -> Result<std::vec::Vec<crate::LocalRaydiumProgramInstructionDiagnosticSummaryDto>, crate::Error>
|
||||
{
|
||||
match database.connection() {
|
||||
crate::DatabaseConnection::Sqlite(pool) => {
|
||||
let rows_result = sqlx::query_as::<
|
||||
@@ -2025,7 +2022,7 @@ HAVING COUNT(DISTINCT CASE
|
||||
AND COUNT(DISTINCT pc.bucket_start_unix || ':' || pc.timeframe_seconds) = 0
|
||||
"#
|
||||
};
|
||||
let sql = format!(
|
||||
let mut builder = sqlx::QueryBuilder::<sqlx::Sqlite>::new(format!(
|
||||
r#"
|
||||
SELECT
|
||||
pair.id AS pair_id,
|
||||
@@ -2070,17 +2067,14 @@ GROUP BY
|
||||
pair.symbol
|
||||
{}
|
||||
ORDER BY decoded_trade_candidate_count DESC, pair.id
|
||||
LIMIT ?
|
||||
"#,
|
||||
LIMIT "#,
|
||||
having_clause
|
||||
);
|
||||
let rows_result = sqlx::query_as::<
|
||||
sqlx::Sqlite,
|
||||
crate::db::dtos::LocalPairGapDiagnosticSampleRow,
|
||||
>(sql.as_str())
|
||||
.bind(limit)
|
||||
.fetch_all(pool)
|
||||
.await;
|
||||
));
|
||||
builder.push_bind(limit);
|
||||
let rows_result = builder
|
||||
.build_query_as::<crate::db::dtos::LocalPairGapDiagnosticSampleRow>()
|
||||
.fetch_all(pool)
|
||||
.await;
|
||||
let rows = match rows_result {
|
||||
Ok(rows) => rows,
|
||||
Err(error) => {
|
||||
|
||||
Reference in New Issue
Block a user