data-observatory: renamed transactions to payments because there is already transaction in the base scraper schema

This commit is contained in:
Mark Sinclair
2024-11-13 11:03:50 +00:00
parent d951ea9548
commit 6010de978d
5 changed files with 10 additions and 6 deletions
@@ -1,4 +1,4 @@
CREATE TABLE transactions (
CREATE TABLE payments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
transaction_hash TEXT NOT NULL UNIQUE,
sender_address TEXT NOT NULL,
+1 -1
View File
@@ -31,7 +31,7 @@ pub(crate) struct PriceHistory {
}
#[derive(Serialize, Deserialize, Debug, ToSchema)]
pub(crate) struct PaymentTransaction {
pub(crate) struct PaymentRecord {
pub(crate) transaction_hash: String,
pub(crate) sender_address: String,
pub(crate) receiver_address: String,
@@ -2,7 +2,7 @@ use crate::db::DbPool;
use anyhow::Result;
pub async fn get_last_checked_height(pool: &DbPool) -> Result<i64> {
let result = sqlx::query_scalar!("SELECT MAX(height) FROM transactions")
let result = sqlx::query_scalar!("SELECT MAX(height) FROM payments")
.fetch_one(pool)
.await?;
Ok(result.unwrap_or(0))
@@ -21,7 +21,7 @@ pub async fn insert_payment(
sqlx::query!(
r#"
INSERT INTO transactions (
INSERT INTO payments (
transaction_hash, sender_address, receiver_address,
amount, height, timestamp, memo
) VALUES (?, ?, ?, ?, ?, ?, ?)
+5 -1
View File
@@ -6,5 +6,9 @@ use utoipauto::utoipauto;
// https://github.com/ProbablyClem/utoipauto/issues/13#issuecomment-1974911829
#[utoipauto(paths = "./nym-data-observatory/src")]
#[derive(OpenApi)]
#[openapi(info(title = "Nym API"), tags(), components(schemas()))]
#[openapi(
info(title = "Nym Data Observatory API"),
tags(),
components(schemas())
)]
pub(super) struct ApiDoc;
@@ -37,7 +37,7 @@ pub(crate) async fn run_payment_listener(
.await?;
for tx in transactions {
println!("Processing transaction: {}", tx.hash);
tracing::info!("Processing transaction: {}", tx.hash);
if let Some(raw_log) = tx.raw_log.as_deref() {
if let Some(transfer) = parse_transfer_from_raw_log(raw_log)? {
if transfer.recipient == payment_receive_address {