Skip to content

Commit

Permalink
feat: exportable members (#20)
Browse files Browse the repository at this point in the history
* feat(exportable_members): Exported schema

* feat(exportable_members): updated package name

* feat(exportable_members): added models to lib

* feat(exportable_members): added types

* feat: checkpoint model

---------

Co-authored-by: 0xevolve <[email protected]>
  • Loading branch information
akhercha and EvolveArt authored May 23, 2024
1 parent 289e0ac commit 5536301
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 37 deletions.
66 changes: 33 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "monitoring"
name = "pragma-monitoring"
version = "0.1.0"
edition = "2021"

Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub(crate) mod config;
pub(crate) mod constants;
pub mod models;
pub mod schema;
pub mod types;
50 changes: 48 additions & 2 deletions src/models.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -43,3 +47,45 @@ pub struct FutureEntry {
pub expiration_timestamp: Option<chrono::NaiveDateTime>,
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<i64>, Bound<i64>),
pub data_id: String,
}
52 changes: 51 additions & 1 deletion src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ diesel::table! {
}

diesel::table! {
spot_entry (timestamp) {
spot_entry (data_id) {
#[max_length = 255]
network -> Varchar,
#[max_length = 255]
Expand All @@ -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]
Expand All @@ -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,
);

0 comments on commit 5536301

Please sign in to comment.