mirror of
https://github.com/glenndehaan/unifi-voucher-site.git
synced 2026-03-31 06:24:02 -04:00
Implemented TASK_CLEANUP_UNUSED_DAYS environment variable. Implemented custom unused cleanup timing. Updated README.md
This commit is contained in:
@@ -172,8 +172,10 @@ services:
|
||||
TRANSLATION_DEBUG: 'false'
|
||||
# Enables/disables an automated task to clean up expired vouchers from UniFi
|
||||
TASK_CLEANUP_EXPIRED: 'false'
|
||||
# Enables/disables an automated task to clean up unused vouchers (Vouchers unused a day after creation) from UniFi
|
||||
# Enables/disables an automated task to clean up unused vouchers from UniFi
|
||||
TASK_CLEANUP_UNUSED: 'false'
|
||||
# Specifies the amount of days to wait before removing the unused vouchers
|
||||
TASK_CLEANUP_UNUSED_DAYS: '1'
|
||||
# Optional volume mapping to override assets
|
||||
volumes:
|
||||
- ./branding:/kiosk
|
||||
@@ -237,7 +239,8 @@ The structure of the file should use lowercase versions of the environment varia
|
||||
"translation_hidden_languages": "",
|
||||
"translation_debug": false,
|
||||
"task_cleanup_expired": false,
|
||||
"task_cleanup_unused": false
|
||||
"task_cleanup_unused": false,
|
||||
"task_cleanup_unused_days": 1
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -55,6 +55,7 @@ module.exports = {
|
||||
translationDebug: config('translation_debug') || (process.env.TRANSLATION_DEBUG === 'true') || false,
|
||||
taskCleanupExpired: config('task_cleanup_expired') || (process.env.TASK_CLEANUP_EXPIRED === 'true') || false,
|
||||
taskCleanupUnused: config('task_cleanup_unused') || (process.env.TASK_CLEANUP_UNUSED === 'true') || false,
|
||||
taskCleanupUnusedDays: config('task_cleanup_unused_days') || process.env.TASK_CLEANUP_UNUSED_DAYS || 1,
|
||||
gitTag: process.env.GIT_TAG || 'master',
|
||||
gitBuild: fs.existsSync('/etc/unifi_voucher_site_build') ? fs.readFileSync('/etc/unifi_voucher_site_build', 'utf-8') : 'Development'
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
const cache = require('../modules/cache');
|
||||
const log = require('../modules/log');
|
||||
const unifi = require('../modules/unifi');
|
||||
const variables = require('../modules/variables');
|
||||
|
||||
/**
|
||||
* Import own utils
|
||||
@@ -39,7 +40,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Function to clean up unused voucher that are still active after a day
|
||||
* Function to clean up unused voucher that are still active after defined day(s)
|
||||
*
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
@@ -48,7 +49,7 @@ module.exports = {
|
||||
const vouchers = cache.vouchers.filter((voucher) => {
|
||||
const today = new Date();
|
||||
const voucherDate = new Date(voucher.createdAt);
|
||||
voucherDate.setDate(voucherDate.getDate() + 1);
|
||||
voucherDate.setDate(voucherDate.getDate() + parseInt(variables.taskCleanupUnusedDays));
|
||||
|
||||
return voucherDate.getTime() < today.getTime();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user