feat: add optional quote_symbol to ticker entity

the quote symbol represents the currency in
which the ticker is quoted. e.g.: USD, ARS, etc
This commit is contained in:
Lucas Colombo 2024-05-23 20:56:58 -03:00
parent b8d83c6fff
commit ff02cb2157
Signed by: lucas
GPG Key ID: EF34786CFEFFAE35
5 changed files with 17 additions and 2 deletions

View File

@ -78,3 +78,10 @@ tasks:
- release:pre
cmds:
- cargo release patch --execute
fmt+lint:
desc: 🎨🧶 format and lint rustler
cmds:
- task fmt
- git add .
- task lint

View File

@ -14,6 +14,7 @@ impl MigrationTrait for Migration {
.if_not_exists()
.col(ColumnDef::new(Ticker::Id).string().not_null().primary_key())
.col(ColumnDef::new(Ticker::Symbol).string().not_null())
.col(ColumnDef::new(Ticker::QuoteSymbol).string().null())
.col(ColumnDef::new(Ticker::MarketId).string().not_null())
.foreign_key(
ForeignKey::create()
@ -45,6 +46,9 @@ enum Ticker {
Id,
/// Ticker symbol (e.g. "GOOGL")
Symbol,
/// Quote symbol (e.g. "USD"): represents the currency in which the ticker is quoted.
/// Could be null, and it will imply USD
QuoteSymbol,
/// Market ID
MarketId,
}

View File

@ -9,6 +9,7 @@ pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
pub symbol: String,
pub quote_symbol: Option<String>,
pub market_id: String,
}

View File

@ -21,7 +21,8 @@ message Empty { }
message Ticker {
string id = 1;
string symbol = 2;
string market_id = 3;
optional string quote_symbol = 3;
string market_id = 4;
}
message Tickers {

View File

@ -20,6 +20,7 @@ impl Ticker {
ticker::Model {
id: self.id,
symbol: self.symbol,
quote_symbol: self.quote_symbol,
market_id: self.market_id,
}
}
@ -29,6 +30,7 @@ impl Ticker {
Self {
id: model.id,
symbol: model.symbol,
quote_symbol: model.quote_symbol,
market_id: model.market_id,
}
}