0.7.30
This commit is contained in:
@@ -26,6 +26,28 @@ SELECT
|
||||
FROM k_sol_dex_decoded_events
|
||||
WHERE json_extract(payload_json, '$.candleCandidate') = 1
|
||||
) AS decoded_candle_candidate_count,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM k_sol_dex_decoded_events
|
||||
WHERE COALESCE(json_extract(payload_json, '$.nonTradeUseful'), 0) = 1
|
||||
OR COALESCE(json_extract(payload_json, '$.eventActionability'), '') = 'non_trade_useful'
|
||||
) AS decoded_non_trade_useful_event_count,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM k_sol_dex_decoded_events
|
||||
WHERE COALESCE(json_extract(payload_json, '$.eventActionability'), '') = 'non_actionable_trade'
|
||||
OR (
|
||||
COALESCE(json_extract(payload_json, '$.eventActionability'), '') = ''
|
||||
AND COALESCE(json_extract(payload_json, '$.eventCategory'), '') = 'trade'
|
||||
AND COALESCE(json_extract(payload_json, '$.tradeCandidate'), 0) = 0
|
||||
AND COALESCE(json_extract(payload_json, '$.transactionFailed'), 0) = 0
|
||||
)
|
||||
) AS decoded_non_actionable_trade_event_count,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM k_sol_dex_decoded_events
|
||||
WHERE COALESCE(json_extract(payload_json, '$.eventCategory'), 'unknown') = 'unknown'
|
||||
) AS decoded_unknown_event_count,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM k_sol_dex_decoded_events dde
|
||||
@@ -250,6 +272,10 @@ SELECT
|
||||
decoded_event_count: row.decoded_event_count,
|
||||
decoded_trade_candidate_count: row.decoded_trade_candidate_count,
|
||||
decoded_candle_candidate_count: row.decoded_candle_candidate_count,
|
||||
decoded_non_trade_useful_event_count: row.decoded_non_trade_useful_event_count,
|
||||
decoded_non_actionable_trade_event_count: row
|
||||
.decoded_non_actionable_trade_event_count,
|
||||
decoded_unknown_event_count: row.decoded_unknown_event_count,
|
||||
missing_trade_event_count: row.missing_trade_event_count,
|
||||
decoded_trade_candidate_without_trade_event_count: row
|
||||
.decoded_trade_candidate_without_trade_event_count,
|
||||
@@ -512,6 +538,9 @@ SELECT
|
||||
dde.protocol_name AS protocol_name,
|
||||
dde.event_kind AS event_kind,
|
||||
json_extract(dde.payload_json, '$.eventCategory') AS event_category,
|
||||
json_extract(dde.payload_json, '$.eventLifecycleKind') AS event_lifecycle_kind,
|
||||
json_extract(dde.payload_json, '$.eventActionability') AS event_actionability,
|
||||
json_extract(dde.payload_json, '$.nonTradeUseful') AS non_trade_useful,
|
||||
json_extract(dde.payload_json, '$.tradeCandidate') AS trade_candidate,
|
||||
json_extract(dde.payload_json, '$.candleCandidate') AS candle_candidate,
|
||||
COUNT(dde.id) AS event_count,
|
||||
@@ -522,6 +551,9 @@ GROUP BY
|
||||
dde.protocol_name,
|
||||
dde.event_kind,
|
||||
event_category,
|
||||
event_lifecycle_kind,
|
||||
event_actionability,
|
||||
non_trade_useful,
|
||||
trade_candidate,
|
||||
candle_candidate
|
||||
ORDER BY
|
||||
@@ -546,6 +578,9 @@ ORDER BY
|
||||
protocol_name: row.protocol_name,
|
||||
event_kind: row.event_kind,
|
||||
event_category: row.event_category,
|
||||
event_lifecycle_kind: row.event_lifecycle_kind,
|
||||
event_actionability: row.event_actionability,
|
||||
non_trade_useful: sqlite_bool_to_option(row.non_trade_useful),
|
||||
trade_candidate: sqlite_bool_to_option(row.trade_candidate),
|
||||
candle_candidate: sqlite_bool_to_option(row.candle_candidate),
|
||||
event_count: row.event_count,
|
||||
@@ -557,6 +592,68 @@ ORDER BY
|
||||
}
|
||||
}
|
||||
|
||||
/// Lists local decoded-event classification diagnostic summaries.
|
||||
pub async fn query_local_event_classification_diagnostic_list_summaries(
|
||||
database: &crate::Database,
|
||||
) -> Result<std::vec::Vec<crate::LocalEventClassificationDiagnosticSummaryDto>, crate::Error> {
|
||||
match database.connection() {
|
||||
crate::DatabaseConnection::Sqlite(pool) => {
|
||||
let rows_result = sqlx::query_as::<
|
||||
sqlx::Sqlite,
|
||||
crate::db::dtos::LocalEventClassificationDiagnosticSummaryRow,
|
||||
>(
|
||||
r#"
|
||||
SELECT
|
||||
COALESCE(json_extract(dde.payload_json, '$.eventCategory'), 'unknown') AS event_category,
|
||||
COALESCE(json_extract(dde.payload_json, '$.eventLifecycleKind'), 'unknown') AS event_lifecycle_kind,
|
||||
COALESCE(json_extract(dde.payload_json, '$.eventActionability'), 'unknown') AS event_actionability,
|
||||
CASE WHEN COALESCE(json_extract(dde.payload_json, '$.nonTradeUseful'), 0) = 1 THEN 1 ELSE 0 END AS non_trade_useful,
|
||||
COUNT(dde.id) AS event_count,
|
||||
COUNT(CASE WHEN COALESCE(json_extract(dde.payload_json, '$.tradeCandidate'), 0) = 1 THEN dde.id END) AS decoded_trade_candidate_count,
|
||||
COUNT(CASE WHEN COALESCE(json_extract(dde.payload_json, '$.candleCandidate'), 0) = 1 THEN dde.id END) AS decoded_candle_candidate_count,
|
||||
COUNT(te.id) AS trade_event_count
|
||||
FROM k_sol_dex_decoded_events dde
|
||||
LEFT JOIN k_sol_trade_events te ON te.decoded_event_id = dde.id
|
||||
GROUP BY
|
||||
event_category,
|
||||
event_lifecycle_kind,
|
||||
event_actionability,
|
||||
non_trade_useful
|
||||
ORDER BY
|
||||
event_category,
|
||||
event_lifecycle_kind,
|
||||
event_actionability
|
||||
"#,
|
||||
)
|
||||
.fetch_all(pool)
|
||||
.await;
|
||||
let rows = match rows_result {
|
||||
Ok(rows) => rows,
|
||||
Err(error) => {
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot list local decoded event classification summaries on sqlite: {}",
|
||||
error
|
||||
)));
|
||||
},
|
||||
};
|
||||
let mut summaries = std::vec::Vec::new();
|
||||
for row in rows {
|
||||
summaries.push(crate::LocalEventClassificationDiagnosticSummaryDto {
|
||||
event_category: row.event_category,
|
||||
event_lifecycle_kind: row.event_lifecycle_kind,
|
||||
event_actionability: row.event_actionability,
|
||||
non_trade_useful: row.non_trade_useful != 0,
|
||||
event_count: row.event_count,
|
||||
decoded_trade_candidate_count: row.decoded_trade_candidate_count,
|
||||
decoded_candle_candidate_count: row.decoded_candle_candidate_count,
|
||||
trade_event_count: row.trade_event_count,
|
||||
});
|
||||
}
|
||||
return Ok(summaries);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Lists missing trade events grouped by diagnostic reason.
|
||||
pub async fn query_local_missing_trade_event_reason_list_summaries(
|
||||
database: &crate::Database,
|
||||
|
||||
Reference in New Issue
Block a user