From 0ac3cf7d291f40dfb06d68f8c895ef3352ce3ac4 Mon Sep 17 00:00:00 2001 From: akhercha Date: Tue, 23 Apr 2024 14:19:11 +0200 Subject: [PATCH 1/5] feat(exportable_members): Exported schema --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/lib.rs diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..1ce7e17 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1 @@ +pub mod schema; From 48fab5891425735726399339fde1f0da90fe6f15 Mon Sep 17 00:00:00 2001 From: akhercha Date: Tue, 23 Apr 2024 14:22:57 +0200 Subject: [PATCH 2/5] feat(exportable_members): updated package name --- Cargo.lock | 66 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31cc8d0..fa4cca2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1323,39 +1323,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "monitoring" -version = "0.1.0" -dependencies = [ - "arc-swap", - "axum", - "axum-macros", - "bigdecimal 0.4.2", - "chrono", - "deadpool", - "diesel", - "diesel-async", - "diesel_derives 1.4.1", - "diesel_migrations", - "dotenv", - "env_logger", - "futures", - "hyper", - "lazy_static", - "log", - "num-bigint", - "phf", - "prometheus", - "reqwest", - "rstest", - "serde", - "starknet", - "strum", - "tokio", - "url", - "uuid 1.6.1", -] - [[package]] name = "multer" version = "2.1.0" @@ -1691,6 +1658,39 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "pragma-monitoring" +version = "0.1.0" +dependencies = [ + "arc-swap", + "axum", + "axum-macros", + "bigdecimal 0.4.2", + "chrono", + "deadpool", + "diesel", + "diesel-async", + "diesel_derives 1.4.1", + "diesel_migrations", + "dotenv", + "env_logger", + "futures", + "hyper", + "lazy_static", + "log", + "num-bigint", + "phf", + "prometheus", + "reqwest", + "rstest", + "serde", + "starknet", + "strum", + "tokio", + "url", + "uuid 1.6.1", +] + [[package]] name = "primitive-types" version = "0.12.2" diff --git a/Cargo.toml b/Cargo.toml index 7daf3c5..a1f5c62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "monitoring" +name = "pragma-monitoring" version = "0.1.0" edition = "2021" From c18777e443a54362330d92deadbf092b24254003 Mon Sep 17 00:00:00 2001 From: akhercha Date: Thu, 23 May 2024 09:09:57 +0200 Subject: [PATCH 3/5] feat(exportable_members): added models to lib --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 1ce7e17..d5cbad7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1 +1,2 @@ +pub mod models; pub mod schema; From 60847bcd34d92ecc08475b8235d16b863ce4875b Mon Sep 17 00:00:00 2001 From: akhercha Date: Thu, 23 May 2024 15:57:46 +0200 Subject: [PATCH 4/5] feat(exportable_members): added types --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index d5cbad7..3d8380a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,3 @@ pub mod models; pub mod schema; +pub mod types; From 02e9b0c7e7184b4335b120dd266a5805eb6644ac Mon Sep 17 00:00:00 2001 From: 0xevolve Date: Thu, 23 May 2024 15:43:52 +0100 Subject: [PATCH 5/5] feat: checkpoint model --- src/lib.rs | 2 ++ src/models.rs | 50 +++++++++++++++++++++++++++++++++++++++++++++++-- src/schema.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 101 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3d8380a..c3310c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +pub(crate) mod config; +pub(crate) mod constants; pub mod models; pub mod schema; pub mod types; diff --git a/src/models.rs b/src/models.rs index 8b47bc9..f7c9254 100644 --- a/src/models.rs +++ b/src/models.rs @@ -1,9 +1,13 @@ -extern crate bigdecimal; -extern crate chrono; +// Generated by diesel_ext + +#![allow(unused)] +#![allow(clippy::all)] use bigdecimal::BigDecimal; use chrono::NaiveDateTime; use diesel::{Queryable, QueryableByName, Selectable}; +use num_bigint::BigInt; +use std::ops::Bound; #[derive(Debug, Queryable, Selectable, QueryableByName)] #[diesel(table_name = crate::schema::spot_entry)] @@ -43,3 +47,45 @@ pub struct FutureEntry { pub expiration_timestamp: Option, pub _cursor: i64, } + +#[derive(Queryable, Debug, QueryableByName, Selectable)] +#[diesel(primary_key(data_id))] +#[diesel(check_for_backend(diesel::pg::Pg))] +#[diesel(table_name = crate::schema::spot_checkpoints)] +pub struct SpotCheckpoint { + pub network: String, + pub pair_id: String, + pub data_id: String, + pub block_hash: String, + pub block_number: i64, + pub block_timestamp: NaiveDateTime, + pub transaction_hash: String, + pub price: BigDecimal, + pub sender_address: String, + pub aggregation_mode: BigDecimal, + pub _cursor: i64, + pub timestamp: NaiveDateTime, + pub nb_sources_aggregated: BigDecimal, +} + +#[derive(Queryable, Debug, QueryableByName, Selectable)] +#[diesel(primary_key(data_id))] +#[diesel(check_for_backend(diesel::pg::Pg))] +#[diesel(table_name = crate::schema::vrf_requests)] +pub struct VrfRequest { + pub network: String, + pub request_id: BigDecimal, + pub seed: BigDecimal, + pub created_at: NaiveDateTime, + pub created_at_tx: String, + pub callback_address: String, + pub callback_fee_limit: BigDecimal, + pub num_words: BigDecimal, + pub requestor_address: String, + pub updated_at: NaiveDateTime, + pub updated_at_tx: String, + pub status: BigDecimal, + pub minimum_block_number: BigDecimal, + pub _cursor: (Bound, Bound), + pub data_id: String, +} diff --git a/src/schema.rs b/src/schema.rs index 3003b96..3f8633d 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -78,7 +78,7 @@ diesel::table! { } diesel::table! { - spot_entry (timestamp) { + spot_entry (data_id) { #[max_length = 255] network -> Varchar, #[max_length = 255] @@ -102,6 +102,54 @@ diesel::table! { } } +diesel::table! { + mainnet_spot_checkpoints (pair_id) { + #[max_length = 255] + network -> Varchar, + #[max_length = 255] + pair_id -> Varchar, + #[max_length = 255] + data_id -> Varchar, + #[max_length = 255] + block_hash -> Varchar, + block_number -> Int8, + block_timestamp -> Timestamp, + #[max_length = 255] + transaction_hash -> Varchar, + price -> Numeric, + #[max_length = 255] + sender_address -> Varchar, + aggregation_mode -> Numeric, + _cursor -> Int8, + timestamp -> Timestamp, + nb_sources_aggregated -> Numeric, + } +} + +diesel::table! { + spot_checkpoints (data_id) { + #[max_length = 255] + network -> Varchar, + #[max_length = 255] + pair_id -> Varchar, + #[max_length = 255] + data_id -> Varchar, + #[max_length = 255] + block_hash -> Varchar, + block_number -> Int8, + block_timestamp -> Timestamp, + #[max_length = 255] + transaction_hash -> Varchar, + price -> Numeric, + #[max_length = 255] + sender_address -> Varchar, + aggregation_mode -> Numeric, + _cursor -> Int8, + timestamp -> Timestamp, + nb_sources_aggregated -> Numeric, + } +} + diesel::table! { vrf_requests (data_id) { #[max_length = 255] @@ -127,7 +175,9 @@ diesel::table! { diesel::allow_tables_to_appear_in_same_query!( future_entry, mainnet_future_entry, + mainnet_spot_checkpoints, mainnet_spot_entry, + spot_checkpoints, spot_entry, vrf_requests, );