35 lines
1.0 KiB
Rust
35 lines
1.0 KiB
Rust
use crate::{
|
|
models::{
|
|
ApiTokenInfo, Automation, ClimateGroup, ConfigurationExport, ConnectionType, Device, DeviceGroup, EnergySourcePreference, EventLog, Flow,
|
|
EnergyReading, HaReading, Reading, RuntimeSettings, Schedule, Zone, ZoneReading,
|
|
},
|
|
queries,
|
|
};
|
|
use anyhow::{Context, Result};
|
|
use chrono::{DateTime, Duration, Utc};
|
|
use rusqlite::{params, Connection, OptionalExtension};
|
|
use serde::{de::DeserializeOwned, Serialize};
|
|
use serde_json::Value;
|
|
use std::{
|
|
path::Path,
|
|
sync::{Arc, Mutex},
|
|
};
|
|
|
|
#[derive(Clone)]
|
|
pub struct Db {
|
|
conn: Arc<Mutex<Connection>>,
|
|
}
|
|
|
|
// Functional source split intentionally keeps items in the existing module namespace.
|
|
include!("db/core_devices.rs");
|
|
include!("db/climate.rs");
|
|
include!("db/schedules_automations.rs");
|
|
include!("db/flows.rs");
|
|
include!("db/device_history.rs");
|
|
include!("db/zone_history.rs");
|
|
include!("db/ha_history.rs");
|
|
include!("db/energy_history.rs");
|
|
include!("db/events_tokens.rs");
|
|
include!("db/configuration.rs");
|
|
include!("db/tests.rs");
|