feat: add package pruning system with configurable grace periods

- Implemented automatic pruning of stale packages across all platform sync endpoints (Arch, AUR, Debian, Ubuntu, Fedora, Homebrew, Winget)
- Added `last_seen_at` tracking to mark packages as seen during sync runs and identify inactive packages
- Introduced `PRUNE_GRACE_DAYS` and `PRUNE_HARD_DELETE_DAYS` environment variables for configurable soft-delete and hard-delete thresholds
This commit is contained in:
Yusuf İpek
2025-11-13 01:54:23 +03:00
parent 560e78cb96
commit ea792a8a7f
15 changed files with 242 additions and 17 deletions
+7 -2
View File
@@ -210,8 +210,8 @@ export class PackageService {
`INSERT INTO packages (
id, name, description, version, platform_id, category_id,
license_id, type, repository, homepage_url, download_url,
popularity_score
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
popularity_score, last_seen_at
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, NOW())
RETURNING *`,
[id, name, description, version, platform_id, category_id,
license_id, type, repository, homepage_url, download_url,
@@ -238,6 +238,11 @@ export class PackageService {
}
}
// Always mark as seen and active on update
fields.push('last_seen_at = NOW()')
fields.push('is_active = true')
fields.push('updated_at = NOW()')
if (fields.length === 0) {
return this.getById(id)
}