Compare commits

..

2 Commits

Author SHA1 Message Date
323dd43c5b
release: 🔖 v0.4.1 2025-03-29 07:10:58 -03:00
4629a02398
feat: add active status to ticker model and related services 2025-03-29 07:10:25 -03:00
7 changed files with 16 additions and 2 deletions

2
Cargo.lock generated
View File

@ -2168,7 +2168,7 @@ dependencies = [
[[package]] [[package]]
name = "rustler-core" name = "rustler-core"
version = "0.4.0" version = "0.4.1"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "rustler-core" name = "rustler-core"
version = "0.4.0" version = "0.4.1"
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>"]

View File

@ -16,6 +16,7 @@ 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")
@ -51,4 +52,6 @@ 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

@ -11,6 +11,7 @@ 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,6 +24,13 @@ 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,6 +23,7 @@ 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,6 +22,7 @@ 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,
} }
} }
@ -32,6 +33,7 @@ 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,
} }
} }
} }