Merge pull request #314

feat(tasks:check_for_updates): add env variable to disable checking
This commit is contained in:
Herculino Trotta
2025-08-06 16:59:15 -03:00
committed by GitHub
4 changed files with 18 additions and 18 deletions
+1
View File
@@ -143,6 +143,7 @@ To create the first user, open the container's console using Unraid's UI, by cli
| DEMO | true\|false | false | If demo mode is enabled. | | DEMO | true\|false | false | If demo mode is enabled. |
| ADMIN_EMAIL | string | None | Automatically creates an admin account with this email. Must have `ADMIN_PASSWORD` also set. | | ADMIN_EMAIL | string | None | Automatically creates an admin account with this email. Must have `ADMIN_PASSWORD` also set. |
| ADMIN_PASSWORD | string | None | Automatically creates an admin account with this password. Must have `ADMIN_EMAIL` also set. | | ADMIN_PASSWORD | string | None | Automatically creates an admin account with this password. Must have `ADMIN_EMAIL` also set. |
| CHECK_FOR_UPDATES | bool | true | Check and notify users about new versions. The check is done by doing a single query to Github's API every 12 hours. |
## OIDC Configuration ## OIDC Configuration
+1
View File
@@ -537,6 +537,7 @@ PWA_APP_SCREENSHOTS = [
PWA_SERVICE_WORKER_PATH = BASE_DIR / "templates" / "pwa" / "serviceworker.js" PWA_SERVICE_WORKER_PATH = BASE_DIR / "templates" / "pwa" / "serviceworker.js"
ENABLE_SOFT_DELETE = os.getenv("ENABLE_SOFT_DELETE", "false").lower() == "true" ENABLE_SOFT_DELETE = os.getenv("ENABLE_SOFT_DELETE", "false").lower() == "true"
CHECK_FOR_UPDATES = os.getenv("CHECK_FOR_UPDATES", "true").lower() == "true"
KEEP_DELETED_TRANSACTIONS_FOR = int(os.getenv("KEEP_DELETED_ENTRIES_FOR", "365")) KEEP_DELETED_TRANSACTIONS_FOR = int(os.getenv("KEEP_DELETED_ENTRIES_FOR", "365"))
APP_VERSION = os.getenv("APP_VERSION", "unknown") APP_VERSION = os.getenv("APP_VERSION", "unknown")
DEMO = os.getenv("DEMO", "false").lower() == "true" DEMO = os.getenv("DEMO", "false").lower() == "true"
+3
View File
@@ -90,6 +90,9 @@ def reset_demo_data(timestamp=None):
name="check_for_updates", name="check_for_updates",
) )
def check_for_updates(timestamp=None): def check_for_updates(timestamp=None):
if not settings.CHECK_FOR_UPDATES:
return "CHECK_FOR_UPDATES is disabled"
url = "https://api.github.com/repos/eitchtee/WYGIWYH/releases/latest" url = "https://api.github.com/repos/eitchtee/WYGIWYH/releases/latest"
try: try:
+1 -6
View File
@@ -28,24 +28,19 @@ def generate_recurring_transactions(timestamp=None):
@app.periodic(cron="10 1 * * *") @app.periodic(cron="10 1 * * *")
@app.task(name="cleanup_deleted_transactions") @app.task(name="cleanup_deleted_transactions")
def cleanup_deleted_transactions(timestamp=None): def cleanup_deleted_transactions(timestamp=None):
with cachalot_disabled():
if settings.ENABLE_SOFT_DELETE and settings.KEEP_DELETED_TRANSACTIONS_FOR == 0: if settings.ENABLE_SOFT_DELETE and settings.KEEP_DELETED_TRANSACTIONS_FOR == 0:
return "KEEP_DELETED_TRANSACTIONS_FOR is 0, no cleanup performed." return "KEEP_DELETED_TRANSACTIONS_FOR is 0, no cleanup performed."
if not settings.ENABLE_SOFT_DELETE: if not settings.ENABLE_SOFT_DELETE:
# Hard delete all soft-deleted transactions # Hard delete all soft-deleted transactions
deleted_count, _ = Transaction.userless_deleted_objects.all().hard_delete() deleted_count, _ = Transaction.userless_deleted_objects.all().hard_delete()
return ( return f"Hard deleted {deleted_count} transactions (soft deletion disabled)."
f"Hard deleted {deleted_count} transactions (soft deletion disabled)."
)
# Calculate the cutoff date # Calculate the cutoff date
cutoff_date = timezone.now() - timedelta( cutoff_date = timezone.now() - timedelta(
days=settings.KEEP_DELETED_TRANSACTIONS_FOR days=settings.KEEP_DELETED_TRANSACTIONS_FOR
) )
invalidate()
# Hard delete soft-deleted transactions older than the cutoff date # Hard delete soft-deleted transactions older than the cutoff date
old_transactions = Transaction.userless_deleted_objects.filter( old_transactions = Transaction.userless_deleted_objects.filter(
deleted_at__lt=cutoff_date deleted_at__lt=cutoff_date