fix: Archival of suspended sites#6139
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #6139 +/- ##
============================================
+ Coverage 51.91% 73.08% +21.16%
============================================
Files 909 111 -798
Lines 75807 17631 -58176
Branches 272 272
============================================
- Hits 39358 12885 -26473
+ Misses 36426 4723 -31703
Partials 23 23
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a suspended_at timestamp on the Site doctype and updates the suspended-site archival workflow to use that field for determining when to notify and when to archive.
Changes:
- Adds
suspended_attoSite, sets it on suspend and clears it on unsuspend. - Adds a patch to backfill
suspended_atfor already-suspended sites using “Suspend Site” activity records. - Splits “notify before archival” into a separate scheduled job and updates tests and email copy accordingly.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| press/templates/emails/notify_before_site_archival.html | Updates notification email wording (“within” instead of “in”). |
| press/press/doctype/site/test_site.py | Updates tests to cover the new notify job + archival behavior using suspended_at. |
| press/press/doctype/site/site.py | Adds suspended_at, updates suspend/unsuspend, rewrites archival selection logic, adds notify job. |
| press/press/doctype/site/site.json | Adds Suspended At field to the Site doctype schema. |
| press/patches/v0_8_0/set_suspended_at_for_suspended_sites.py | Backfills suspended_at for existing suspended sites. |
| press/patches.txt | Registers the new patch. |
| press/hooks.py | Schedules the new notify job to run hourly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .where( | ||
| (sites.status == "Suspended") & (sites.trial_end_date.isnull()) & (site_plans.is_trial_plan == 0) | ||
| (SiteTable.status == "Suspended") | ||
| & (SiteTable.suspended_at.isnotnull()) | ||
| & (SiteTable.suspended_at <= archive_threshold) | ||
| ) |
| archive_suspended_site(site_dict) | ||
| frappe.db.commit() | ||
| if frappe.db.get_value("Bench", site_dict.bench, "managed_database_service"): | ||
| return |
| return | ||
|
|
||
| site = Site("Site", site_dict.name) | ||
| site.archive(reason="Archive suspended site") |
| SiteTable = frappe.qb.DocType("Site") | ||
| sites_to_notify = ( | ||
| frappe.qb.from_(SiteTable) | ||
| .where( | ||
| (SiteTable.status == "Suspended") | ||
| & (SiteTable.suspended_at.isnotnull()) | ||
| & (SiteTable.suspended_at <= notify_threshold) | ||
| & (SiteTable.suspended_at > archive_threshold) |
- Patch to populate `suspended_at` field in Site doctype based on 'Suspend Site' activity record's creation
…tion respectively
- Filter based on newly added suspended_at field value - Move out logic for notifying user before archival
- Add it as a separate job - Filter sites based on suspended_at field
- Remove press/press/doctype/site/archive.py file which had logic for: - Archiving suspended trial sites - Deleting offsite backups of archived sites, this is already handled
270d2bf to
9de3027
Compare
|
@mergify backport master |
✅ Backports have been createdDetails
|
suspended_atfield to Site doctype to track site suspension timesuspended_atfield in Site doctype based on 'Suspend Site' activity record's creationsuspended_atfield on site suspension and activation respectively