Skip to content

feat: sparkline chart for campaign funding momentum #28

@Jing-yilin

Description

@Jing-yilin

Overview

Display a sparkline chart on each campaign card (similar to GitHub's repository activity graph) showing pledged amount growth over time.

Motivation

A time-series funding chart gives users instant visual signal of a campaign's momentum — is it accelerating, stagnating, or surging in the final days?

Required Changes

Backend

  1. New campaign_snapshots table

    • Fields: campaign_pid, pledged_amount, backers_count, recorded_at
    • Unique constraint on (campaign_pid, DATE(recorded_at)) — one snapshot per day
  2. Cron hook — after each nightly crawl, upsert a snapshot for every discovered campaign

  3. New API endpoint

    GET /api/campaigns/:pid/history
    

    Returns ordered array of { recorded_at, pledged_amount, backers_count }

iOS

  1. Add CampaignSnapshot model and fetchHistory(pid:) in APIClient
  2. Render sparkline using Swift Charts (built-in, iOS 16+, no extra dependency) on each campaign card
  3. chartXAxis(.hidden) + chartYAxis(.hidden) for compact inline display

Constraints

  • Sparkline requires ≥ 3 data points to be meaningful; show a static progress bar (percent_funded) as fallback until enough history is collected
  • One snapshot per campaign per day — do not store duplicates within the same calendar day

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions