Skip to content

fix: Archival of suspended sites#6139

Merged
AyshaHakeem merged 7 commits intofrappe:developfrom
AyshaHakeem:fix-suspended-sites-archival
Apr 16, 2026
Merged

fix: Archival of suspended sites#6139
AyshaHakeem merged 7 commits intofrappe:developfrom
AyshaHakeem:fix-suspended-sites-archival

Conversation

@AyshaHakeem
Copy link
Copy Markdown
Collaborator

@AyshaHakeem AyshaHakeem commented Apr 16, 2026

  • Add suspended_at field to Site doctype to track site suspension time
  • Add Patch to populate suspended_at field in Site doctype based on 'Suspend Site' activity record's creation
  • Set and unset suspended_at field on site suspension and activation respectively
  • Update archive_suspended_sites job
    • Filter based on the newly added suspended_at field value
    • Move out logic for notifying the user before archival into a separate job
  • Add test

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.08%. Comparing base (baee479) to head (9de3027).
⚠️ Report is 9 commits behind head on develop.

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               
Flag Coverage Δ
dashboard 73.08% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_at to Site, sets it on suspend and clears it on unsuspend.
  • Adds a patch to backfill suspended_at for 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.

Comment on lines 5127 to 5131
.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)
)
Comment thread press/press/doctype/site/site.py Outdated
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")
Comment on lines +5157 to +5164
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
- 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
@AyshaHakeem AyshaHakeem force-pushed the fix-suspended-sites-archival branch from 270d2bf to 9de3027 Compare April 16, 2026 11:29
@AyshaHakeem AyshaHakeem merged commit ba809cc into frappe:develop Apr 16, 2026
7 checks passed
@AyshaHakeem
Copy link
Copy Markdown
Collaborator Author

@mergify backport master

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 16, 2026

backport master

✅ Backports have been created

Details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants