mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Add support for rules per day
This commit is contained in:
@@ -54,7 +54,8 @@ export async function dispatchCreateTimeLimitRule ({ action, cache, fromChildSel
|
||||
startMinuteOfDay: action.rule.start,
|
||||
endMinuteOfDay: action.rule.end,
|
||||
sessionDurationMilliseconds: action.rule.sessionDurationMilliseconds,
|
||||
sessionPauseMilliseconds: action.rule.sessionPauseMilliseconds
|
||||
sessionPauseMilliseconds: action.rule.sessionPauseMilliseconds,
|
||||
perDay: action.rule.perDay ? 1 : 0
|
||||
}, { transaction: cache.transaction })
|
||||
|
||||
cache.categoriesWithModifiedTimeLimitRules.add(action.rule.categoryId)
|
||||
|
||||
@@ -42,6 +42,7 @@ export async function dispatchUpdateTimelimitRule ({ action, cache }: {
|
||||
ruleEntry.endMinuteOfDay = action.end
|
||||
ruleEntry.sessionDurationMilliseconds = action.sessionDurationMilliseconds
|
||||
ruleEntry.sessionPauseMilliseconds = action.sessionPauseMilliseconds
|
||||
ruleEntry.perDay = action.perDay ? 1 : 0
|
||||
|
||||
await ruleEntry.save({ transaction: cache.transaction })
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ export async function getRules ({ database, transaction, categoryIdsToSyncRules,
|
||||
'startMinuteOfDay',
|
||||
'endMinuteOfDay',
|
||||
'sessionDurationMilliseconds',
|
||||
'sessionPauseMilliseconds'
|
||||
'sessionPauseMilliseconds',
|
||||
'perDay'
|
||||
],
|
||||
transaction
|
||||
})).map((item) => ({
|
||||
@@ -56,7 +57,8 @@ export async function getRules ({ database, transaction, categoryIdsToSyncRules,
|
||||
startMinuteOfDay: item.startMinuteOfDay,
|
||||
endMinuteOfDay: item.endMinuteOfDay,
|
||||
sessionDurationMilliseconds: item.sessionDurationMilliseconds,
|
||||
sessionPauseMilliseconds: item.sessionPauseMilliseconds
|
||||
sessionPauseMilliseconds: item.sessionPauseMilliseconds,
|
||||
perDay: item.perDay
|
||||
}))
|
||||
|
||||
const getCategoryRulesVersion = (categoryId: string) => (
|
||||
@@ -73,7 +75,8 @@ export async function getRules ({ database, transaction, categoryIdsToSyncRules,
|
||||
start: item.startMinuteOfDay,
|
||||
end: item.endMinuteOfDay,
|
||||
session: item.sessionDurationMilliseconds,
|
||||
pause: item.sessionPauseMilliseconds
|
||||
pause: item.sessionPauseMilliseconds,
|
||||
perDay: item.perDay !== 0 ? true : false
|
||||
})),
|
||||
version: getCategoryRulesVersion(categoryId)
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user