import { getRowById, insertRowWithId, updateRow } from '../crud' import type { AppSettings } from '../../../src/db/types' /** Muss mit DEFAULT_RATING_TREND_WEIGHT_STEP in src/config/constants.ts synchron gehalten werden. */ const DEFAULT_RATING_TREND_WEIGHT_STEP = 0.5 export function getRatingTrendWeightStep(): number { const settings = getRowById('appSettings', 1) return settings?.ratingTrendWeightStep ?? DEFAULT_RATING_TREND_WEIGHT_STEP } export function getOrSeedRatingTrendWeightStep(): number { let settings = getRowById('appSettings', 1) if (!settings) { insertRowWithId('appSettings', 1, { ratingTrendWeightStep: DEFAULT_RATING_TREND_WEIGHT_STEP }) settings = getRowById('appSettings', 1) } return settings?.ratingTrendWeightStep ?? DEFAULT_RATING_TREND_WEIGHT_STEP } export function saveRatingTrendWeightStep(weightStep: number): number { const existing = getRowById('appSettings', 1) if (existing) updateRow('appSettings', 1, { ratingTrendWeightStep: weightStep }) else insertRowWithId('appSettings', 1, { ratingTrendWeightStep: weightStep }) return 1 }