diff --git a/lib/entities/migration/m20240325_200049_create_table_ticker.rs b/lib/entities/migration/m20240325_200049_create_table_ticker.rs index 5be4d44..1faa5ac 100644 --- a/lib/entities/migration/m20240325_200049_create_table_ticker.rs +++ b/lib/entities/migration/m20240325_200049_create_table_ticker.rs @@ -16,6 +16,7 @@ impl MigrationTrait for Migration { .col(ColumnDef::new(Ticker::Symbol).string().not_null()) .col(ColumnDef::new(Ticker::QuoteSymbol).string().null()) .col(ColumnDef::new(Ticker::MarketId).string().not_null()) + .col(ColumnDef::new(Ticker::Active).boolean().not_null().default(true)) .foreign_key( ForeignKey::create() .name("fk_ticker_market_id") @@ -51,4 +52,6 @@ enum Ticker { QuoteSymbol, /// Market ID MarketId, + /// Active status of the ticker. This defines if quotes are generated for this ticker or not. + Active, } diff --git a/lib/entities/orm/ticker.rs b/lib/entities/orm/ticker.rs index 1b341e0..229ed93 100644 --- a/lib/entities/orm/ticker.rs +++ b/lib/entities/orm/ticker.rs @@ -11,6 +11,7 @@ pub struct Model { pub symbol: String, pub quote_symbol: Option, pub market_id: String, + pub active: bool, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/lib/entities/services/ticker.rs b/lib/entities/services/ticker.rs index 36a3fad..8016ab5 100644 --- a/lib/entities/services/ticker.rs +++ b/lib/entities/services/ticker.rs @@ -24,6 +24,13 @@ impl Service { Ok(tickers) } + /// ๐ŸŽ ยป get all active + pub async fn get_all_active(&self) -> Result, 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 pub async fn get(&self, id: String) -> Result, DbErr> { let ticker = Ticker::find_by_id(id).one(&self.conn).await?; diff --git a/lib/grpc/proto/ticker.proto b/lib/grpc/proto/ticker.proto index 7fe995f..2f8070b 100644 --- a/lib/grpc/proto/ticker.proto +++ b/lib/grpc/proto/ticker.proto @@ -23,6 +23,7 @@ message Ticker { string symbol = 2; optional string quote_symbol = 3; string market_id = 4; + bool active = 5; } message Tickers { diff --git a/lib/grpc/services/ticker.rs b/lib/grpc/services/ticker.rs index bd1079c..f6bd8b3 100644 --- a/lib/grpc/services/ticker.rs +++ b/lib/grpc/services/ticker.rs @@ -22,6 +22,7 @@ impl Ticker { symbol: self.symbol, quote_symbol: self.quote_symbol, market_id: self.market_id, + active: self.active, } } @@ -32,6 +33,7 @@ impl Ticker { symbol: model.symbol, quote_symbol: model.quote_symbol, market_id: model.market_id, + active: model.active, } } }