add market and odds endpoints
This commit is contained in:
@@ -5,12 +5,15 @@ use sqlx::PgPool;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub use crate::events::{EventManifestSnapshot, EventSnapshot};
|
||||
pub use crate::events::{MarketSnapshot, OutcomeSnapshot};
|
||||
pub use crate::markets::{OddsVersionSnapshot, OutcomeOddsSnapshot};
|
||||
pub use crate::sessions::{SessionSnapshot, SessionStartRequest};
|
||||
|
||||
use crate::{
|
||||
config::AppConfig,
|
||||
error::AppError,
|
||||
events::{EventsStore},
|
||||
markets::MarketsStore,
|
||||
sessions::{SessionDefaults, SessionsStore},
|
||||
users::{UserCreateRequest, UsersStore},
|
||||
};
|
||||
@@ -22,6 +25,7 @@ pub struct AppState {
|
||||
pub database_pool: Option<PgPool>,
|
||||
pub redis_client: Option<RedisClient>,
|
||||
events: EventsStore,
|
||||
markets: MarketsStore,
|
||||
users: UsersStore,
|
||||
sessions: SessionsStore,
|
||||
}
|
||||
@@ -38,6 +42,7 @@ impl AppState {
|
||||
database_pool,
|
||||
redis_client,
|
||||
events: EventsStore::new(),
|
||||
markets: MarketsStore::new(),
|
||||
users: UsersStore::new(),
|
||||
sessions: SessionsStore::new(),
|
||||
}
|
||||
@@ -96,6 +101,14 @@ impl AppState {
|
||||
self.events.get_manifest(event_id).await
|
||||
}
|
||||
|
||||
pub async fn markets_for_event(&self, event_id: Uuid) -> Option<Vec<MarketSnapshot>> {
|
||||
self.markets.markets_for_event(event_id).await
|
||||
}
|
||||
|
||||
pub async fn current_odds(&self, market_id: Uuid) -> Option<OddsVersionSnapshot> {
|
||||
self.markets.current_odds(market_id).await
|
||||
}
|
||||
|
||||
pub fn database_ready(&self) -> bool {
|
||||
self.database_pool.is_some()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user