// rocie - An enterprise grocery management system // // Copyright (C) 2026 Benedikt Peetz // SPDX-License-Identifier: GPL-3.0-or-later // // This file is part of Rocie. // // You should have received a copy of the License along with this program. // If not, see . use crate::{app::App, storage::sql::config::Config}; use sqlx::query; impl Config { pub(crate) async fn get(app: &App) -> Result { let record = query!( " SELECT use_defaults FROM rocie_config WHERE id = 0 " ) .fetch_one(&app.db) .await?; let should_use_defaults = if record.use_defaults == 1 { true } else if record.use_defaults == 0 { false } else { unreachable!("Should not be possible, sqlite's CHECK prevents it") }; Ok(Self { should_use_defaults, }) } } pub(crate) mod get { use actix_web::ResponseError; #[derive(thiserror::Error, Debug)] pub(crate) enum Error { #[error("Failed to execute the sql query")] SqlError(#[from] sqlx::Error), } impl ResponseError for Error {} }