Update
This commit is contained in:
1 parent
911dcace72
commit
9c68c414d8
53 files changed
+2919
-469
No files matched your search
@@ -0,0 +1,26 @@
|
||||
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>('appSettings', 1)
|
||||
return settings?.ratingTrendWeightStep ?? DEFAULT_RATING_TREND_WEIGHT_STEP
|
||||
}
|
||||
|
||||
export function getOrSeedRatingTrendWeightStep(): number {
|
||||
let settings = getRowById<AppSettings>('appSettings', 1)
|
||||
if (!settings) {
|
||||
insertRowWithId('appSettings', 1, { ratingTrendWeightStep: DEFAULT_RATING_TREND_WEIGHT_STEP })
|
||||
settings = getRowById<AppSettings>('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
|
||||
}
|
||||
Reference in new issue
Block a user