Compare commits

..

No commits in common. "master" and "v0.3.10" have entirely different histories.

10 changed files with 394 additions and 629 deletions

View File

@ -1,6 +1,8 @@
[registries.lugit] [registries.lugit]
index = "sparse+https://git.lucode.dev/api/packages/lucas/cargo/" index = "sparse+http://lugit.local/api/packages/lucodear/cargo/"
[registries.lugit-sa]
index = "sparse+http://lugit.local/api/packages/singleaction/cargo/"
[registry] [registry]
global-credential-providers = ["cargo:token"] global-credential-providers = ["cargo:token"]

992
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package] [package]
name = "rustler-core" name = "rustler-core"
version = "0.4.1" version = "0.3.10"
edition = "2021" edition = "2021"
description = "🐎 » rustler-core market data extractor core functionality" description = "🐎 » rustler-core market data extractor core functionality"
authors = ["Lucas Colombo <lucas@lucode.ar>"] authors = ["Lucas Colombo <lucas@lucode.ar>"]
@ -45,7 +45,7 @@ redis = { version = "0.29.2", features = ["tokio-comp"] }
serde = { version = "1.0.219", features = ["derive"] } serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140" serde_json = "1.0.140"
uuid = { version = "1.16.0", features = ["v4", "fast-rng"] } uuid = { version = "1.16.0", features = ["v4", "fast-rng"] }
lool = { version = "^0.9.0", registry = "lugit", features = [ lool = { version = "^0.3.2", registry = "lugit", features = [
"cli.stylize", "cli.stylize",
"logger", "logger",
"sched.tokio", "sched.tokio",

View File

@ -16,7 +16,6 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Ticker::Symbol).string().not_null()) .col(ColumnDef::new(Ticker::Symbol).string().not_null())
.col(ColumnDef::new(Ticker::QuoteSymbol).string().null()) .col(ColumnDef::new(Ticker::QuoteSymbol).string().null())
.col(ColumnDef::new(Ticker::MarketId).string().not_null()) .col(ColumnDef::new(Ticker::MarketId).string().not_null())
.col(ColumnDef::new(Ticker::Active).boolean().not_null().default(true))
.foreign_key( .foreign_key(
ForeignKey::create() ForeignKey::create()
.name("fk_ticker_market_id") .name("fk_ticker_market_id")
@ -52,6 +51,4 @@ enum Ticker {
QuoteSymbol, QuoteSymbol,
/// Market ID /// Market ID
MarketId, MarketId,
/// Active status of the ticker. This defines if quotes are generated for this ticker or not.
Active,
} }

View File

@ -35,20 +35,21 @@ pub mod db {
}, },
}; };
const DATABASE_URL: &str = "DATABASE_URL"; const RUSTLER_DATABASE: &str = "RUSTLER_DATABASE";
fn get_default_conn_str() -> String { fn get_default_conn_str() -> String {
let conn_str = s!("sqlite://rustler.db?mode=rwc"); let conn_str = s!("sqlite://rustler.db?mode=rwc");
info!( info!(
"No `{}` env var found, using default: {}", "No `{}` env var found, using default: {}",
DATABASE_URL.italic(), RUSTLER_DATABASE.italic(),
conn_str.green() conn_str.green()
); );
conn_str conn_str
} }
pub async fn get_connection() -> Result<DatabaseConnection> { pub async fn get_connection() -> Result<DatabaseConnection> {
let db_conn_str = std::env::var(DATABASE_URL).unwrap_or_else(|_| get_default_conn_str()); let db_conn_str =
std::env::var(RUSTLER_DATABASE).unwrap_or_else(|_| get_default_conn_str());
let mut conn_opts = ConnectOptions::new(db_conn_str.to_owned()); let mut conn_opts = ConnectOptions::new(db_conn_str.to_owned());
conn_opts.sqlx_logging(false); conn_opts.sqlx_logging(false);

View File

@ -11,7 +11,6 @@ pub struct Model {
pub symbol: String, pub symbol: String,
pub quote_symbol: Option<String>, pub quote_symbol: Option<String>,
pub market_id: String, pub market_id: String,
pub active: bool,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@ -24,13 +24,6 @@ impl Service {
Ok(tickers) Ok(tickers)
} }
/// 🐎 » get all active
pub async fn get_all_active(&self) -> Result<Vec<TickerModel>, DbErr> {
let tickers =
Ticker::find().filter(ticker::Column::Active.eq(true)).all(&self.conn).await?;
Ok(tickers)
}
/// 🐎 » retrieves a ticker from the database, given its id /// 🐎 » retrieves a ticker from the database, given its id
pub async fn get(&self, id: String) -> Result<Option<TickerModel>, DbErr> { pub async fn get(&self, id: String) -> Result<Option<TickerModel>, DbErr> {
let ticker = Ticker::find_by_id(id).one(&self.conn).await?; let ticker = Ticker::find_by_id(id).one(&self.conn).await?;

View File

@ -23,7 +23,6 @@ message Ticker {
string symbol = 2; string symbol = 2;
optional string quote_symbol = 3; optional string quote_symbol = 3;
string market_id = 4; string market_id = 4;
bool active = 5;
} }
message Tickers { message Tickers {

View File

@ -22,7 +22,6 @@ impl Ticker {
symbol: self.symbol, symbol: self.symbol,
quote_symbol: self.quote_symbol, quote_symbol: self.quote_symbol,
market_id: self.market_id, market_id: self.market_id,
active: self.active,
} }
} }
@ -33,7 +32,6 @@ impl Ticker {
symbol: model.symbol, symbol: model.symbol,
quote_symbol: model.quote_symbol, quote_symbol: model.quote_symbol,
market_id: model.market_id, market_id: model.market_id,
active: model.active,
} }
} }
} }

View File

@ -1,7 +1,7 @@
allow-branch = ["master"] allow-branch = ["master"]
sign-commit = true sign-commit = true
sign-tag = true sign-tag = true
registry = "lugit" registry = "lugit-sa"
pre-release-commit-message = "release: 🔖 v{{version}}" pre-release-commit-message = "release: 🔖 v{{version}}"
tag-message = "release: 🔖 v{{version}}" tag-message = "release: 🔖 v{{version}}"
tag-prefix = "" tag-prefix = ""