mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-13 17:22:49 +00:00
Revert to use local consts instead of config vars
This commit is contained in:
@@ -4,7 +4,7 @@ export const HISTORY_PREFIX = 'HOMEBREWERY-HISTORY';
|
|||||||
export const HISTORY_SLOTS = 5;
|
export const HISTORY_SLOTS = 5;
|
||||||
|
|
||||||
// History values in minutes
|
// History values in minutes
|
||||||
const DEFAULT_HISTORY_SAVE_DELAYS = {
|
const HISTORY_SAVE_DELAYS = {
|
||||||
'0' : 0,
|
'0' : 0,
|
||||||
'1' : 2,
|
'1' : 2,
|
||||||
'2' : 10,
|
'2' : 10,
|
||||||
@@ -16,10 +16,7 @@ const DEFAULT_HISTORY_SAVE_DELAYS = {
|
|||||||
const HB_DB = 'HOMEBREWERY-DB';
|
const HB_DB = 'HOMEBREWERY-DB';
|
||||||
const HB_STORE = 'HISTORY';
|
const HB_STORE = 'HISTORY';
|
||||||
|
|
||||||
const DEFAULT_GARBAGE_COLLECT_DELAY = 28 * 24 * 60;
|
const GARBAGE_COLLECT_DELAY = 28 * 24 * 60;
|
||||||
|
|
||||||
let HISTORY_SAVE_DELAYS = DEFAULT_HISTORY_SAVE_DELAYS;
|
|
||||||
let GARBAGE_COLLECT_DELAY = DEFAULT_GARBAGE_COLLECT_DELAY;
|
|
||||||
|
|
||||||
|
|
||||||
function getKeyBySlot(brew, slot){
|
function getKeyBySlot(brew, slot){
|
||||||
@@ -40,10 +37,6 @@ function parseBrewForStorage(brew, slot = 0) {
|
|||||||
expireAt : new Date()
|
expireAt : new Date()
|
||||||
};
|
};
|
||||||
|
|
||||||
if(global.config?.history?.HISTORY_SAVE_DELAYS){
|
|
||||||
HISTORY_SAVE_DELAYS = global.config?.history?.HISTORY_SAVE_DELAYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
archiveBrew.expireAt.setMinutes(archiveBrew.expireAt.getMinutes() + HISTORY_SAVE_DELAYS[slot]);
|
archiveBrew.expireAt.setMinutes(archiveBrew.expireAt.getMinutes() + HISTORY_SAVE_DELAYS[slot]);
|
||||||
|
|
||||||
const key = getKeyBySlot(brew, slot);
|
const key = getKeyBySlot(brew, slot);
|
||||||
@@ -129,7 +122,6 @@ export async function updateHistory(brew) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function versionHistoryGarbageCollection(){
|
export async function versionHistoryGarbageCollection(){
|
||||||
if(global.config?.history?.GARBAGE_COLLECT_DELAY != GARBAGE_COLLECT_DELAY) GARBAGE_COLLECT_DELAY = global.config?.history?.GARBAGE_COLLECT_DELAY;
|
|
||||||
|
|
||||||
await IDB.entries(await createHBStore())
|
await IDB.entries(await createHBStore())
|
||||||
.then((entries)=>{
|
.then((entries)=>{
|
||||||
|
|||||||
@@ -475,8 +475,7 @@ const renderPage = async (req, res)=>{
|
|||||||
const configuration = {
|
const configuration = {
|
||||||
local : isLocalEnvironment,
|
local : isLocalEnvironment,
|
||||||
publicUrl : config.get('publicUrl') ?? '',
|
publicUrl : config.get('publicUrl') ?? '',
|
||||||
environment : nodeEnv,
|
environment : nodeEnv
|
||||||
history : config.get('historyConfig') ?? {}
|
|
||||||
};
|
};
|
||||||
const props = {
|
const props = {
|
||||||
version : require('./../package.json').version,
|
version : require('./../package.json').version,
|
||||||
|
|||||||
Reference in New Issue
Block a user