Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in
U
upgrade-data-crawler-be
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • ThinhNC
  • upgrade-data-crawler-be
  • Merge Requests
  • !19

Merged
Opened Sep 10, 2026 by ThinhNC@ThinhNC
  • Report abuse
Report abuse

feat(system-config): sync configs with .env and add 7-day retention cron jobs

Summary of Changes

1. 7-Day Retention Cleanup Cron Jobs

  • BullMQ Cron Implementation: Added cleanup-exports scheduled job running daily at 03:00 AM (0 3 * * *), complementing the existing cleanup-audit-logs job at 02:00 AM (0 2 * * *).
  • Retention Period: Updated default retention policy from 30 days to 7 days (DEFAULT_AUDIT_LOG_RETENTION_DAYS = 7, DEFAULT_EXPORT_RETENTION_DAYS = 7).
  • Storage Cleanup: Automatically deletes both database records and physical export files via StorageService.deleteFile() (supporting AWS S3, Supabase Storage, and local disk).
  • Dynamic Configuration & Feature Flags: Integrated SystemConfigService dynamic checks for retention.audit_logs_days, retention.exports_days, feature.cron.cleanup_audit_logs.enabled, and feature.cron.cleanup_exports.enabled.

2. Synchronization of System Configs & Feature Flags with .env

  • Environment Driven Defaults: Updated DEFAULT_SYSTEM_CONFIGS in system-config.constant.ts to dynamically resolve values from process.env.*:
    • Supabase Storage / S3 configs: S3_ENDPOINT, S3_REGION, S3_BUCKET, S3_FORCE_PATH_STYLE, STORAGE_DRIVER, STORAGE_EXPORT_DIR.
    • Crawler, JWT, Quota, Rate Limit, SMTP, and Firecrawl configurations.
  • Upsert Value Sync: Updated ensureDefault in system-config.repository.ts and ensureDefaultConfigs(syncValues = true) in system-config.service.ts to update existing database values during initialization or synchronization.
  • New API Endpoint: Added POST /api/v1/system/configs/sync-env protected by system_configs.manage permission to trigger immediate sync and flush Redis cache on demand.
  • Migration Script: Enhanced scripts/sync-system-configs.ts (pnpm config:sync) to upsert values into Postgres.

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b feat/cron-retention-and-env-config-sync origin/feat/cron-retention-and-env-config-sync

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout origin/develop
git merge --no-ff feat/cron-retention-and-env-config-sync

Step 4. Push the result of the merge to GitLab

git push origin develop

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

  • Discussion 0
  • Commits 1
  • Changes 14
Assignee
No assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View project labels
Reference: ThinhNC/upgrade-data-crawler-be!19

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.