use chrono::{DateTime, NaiveDate, Utc};
use sqlx::FromRow;

#[derive(Debug, Clone, FromRow)]
pub struct IngestConfigRow {
    pub id: i32,
    pub instrument_id: i32,
    pub source: String,
    pub source_type: String,
    pub retention_days: i32,
    pub candle_retention_days: Option<i32>,
    pub active: bool,
    pub last_ingested_date: Option<NaiveDate>,
    pub candle_intervals: Vec<String>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
}

/// Enriched view for the API: ingest_config joined with instrument and exchange.
#[derive(Debug, Clone, FromRow)]
pub struct EnrichedIngestConfigRow {
    pub id: i32,
    pub instrument_id: i32,
    pub source: String,
    pub source_type: String,
    pub retention_days: i32,
    pub candle_retention_days: Option<i32>,
    pub active: bool,
    pub last_ingested_date: Option<NaiveDate>,
    pub candle_intervals: Vec<String>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
    pub exchange_name: String,
    pub base_asset: String,
    pub quote_asset: String,
}

/// Enriched view joining ingest_config with the instrument's exchange symbol.
#[derive(Debug, Clone, FromRow)]
pub struct ActiveIngestConfigRow {
    pub id: i32,
    pub instrument_id: i32,
    pub symbol: String,
    pub source: String,
    pub source_type: String,
    pub retention_days: i32,
    pub candle_retention_days: Option<i32>,
    pub last_ingested_date: Option<NaiveDate>,
    pub candle_intervals: Vec<String>,
}
