Skip to content

[Feature] Implement automated pool archival and cleanup for completed/inactive pools with data preservation #212

Description

@Sendi0011

Getting Started

  1. Fork the repository: https://github.com/JointSave-org/Joint_Save
  2. Clone your fork:
git clone https://github.com/<your-username>/Joint_Save.git
cd Joint_Save
  1. Create a new branch:
git checkout -b feat/pool-archival-cleanup

Overview

As JointSave grows, completed and inactive pools accumulate in the Explore page and My Groups tab, cluttering the UI and degrading performance. Currently, there is no mechanism to archive completed pools, remove inactive pools from discovery, or clean up stale data. The pools table in Supabase has a status column but no automated transitions occur.

Checked frontend/app/explore/page.tsx — fetches all pools via /api/pools without filtering by status. The My Groups tab shows all pools the user is a member of regardless of completion status. Pool contracts remain deployed on-chain indefinitely.

This issue adds an automated archival system that identifies completed/inactive pools, moves them to an archived state, hides them from discovery views (while preserving historical data), and provides an archival dashboard for reviewing past pools.

Requirements

Database Changes

  • Add to pools table:
    • archived_at (timestamptz, nullable)
    • archive_reason (text, nullable): completed, inactive_90d, admin_archived, emergency_withdrawn
  • Migration: ALTER TABLE pools ADD COLUMN archived_at timestamptz, ADD COLUMN archive_reason text

Automated Archival Logic

  • New Vercel Cron endpoint: POST /api/cron/archive-pools
    • Runs daily at 02:00 UTC
    • Criteria for archival:
      1. Completed pools: status = 'completed' and completed_at is older than 7 days (grace period for viewing)
      2. Inactive pools: no activity in pool_activity for 90 days AND all members have empty deposits (never deposited or fully withdrawn)
      3. Emergency withdrawn: status = 'emergency_withdrawn' and emergency_withdrawn_at is older than 30 days
    • Sets archived_at and archive_reason for matching pools
    • Sends a summary notification to each affected pool's admin
    • Logs archival actions in a new archive_log table

Frontend Changes

  • Modify Explore page:

    • Exclude archived pools from the default query
    • Add a "Show Archived" toggle (off by default)
    • Archived pools show a grayed-out card with "Archived" badge
  • Modify My Groups page:

    • Separate tabs: "Active" and "Archived"
    • Archived tab shows completed/inactive pools in a compact list view
    • Each archived pool shows: name, type, completion date, final TVL, reason for archival
  • New component: frontend/components/shared/archived-pool-card.tsx

    • Compact card for archived pools
    • Shows pool name, type, archived date, reason
    • "View History" button that opens a read-only view of the pool detail page
  • Modify pool detail page for archived pools:

    • All data is read-only (no deposit/withdraw/pause buttons)
    • "Archived" banner at the top explaining the archival reason
    • Activity feed still accessible but marked as historical
    • "This pool has been archived and is no longer active" message

API Changes

  • GET /api/pools — add archived query param (default: false) to include/exclude archived pools
  • PUT /api/pools/[id]/archive — manual admin archival (body: reason)
  • PUT /api/pools/[id]/unarchive — reverse archival (admin only)

Data Preservation

  • Archived pools retain all Supabase data (pool metadata, members, activity)
  • On-chain contract data is immutable and unaffected
  • Archived pools can still be viewed in read-only mode
  • Historical data export remains available for archived pools

Acceptance Criteria

  • Cron job correctly identifies completed, inactive, and emergency-withdrawn pools
  • Archived pools are hidden from Explore and My Groups by default
  • Archived pools can be viewed with a toggle/tab
  • Archived pool detail pages are fully read-only
  • Admins can manually archive and unarchive pools
  • Archival actions are logged in the archive_log table
  • Archived pools retain all historical data and activity
  • "Show Archived" toggle works correctly on Explore page
  • Archived tab on My Groups shows compact list of past pools
  • No performance degradation on Explore/My Groups pages after archival

Activity

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignfeatureNew functionality to addhigh-complexityLarge scope, multiple systems/files. Needs planning

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions