Skip to content

Instantly share code, notes, and snippets.

@felipevelzani
Last active January 8, 2026 18:00
Show Gist options
  • Select an option

  • Save felipevelzani/3bd32fb16467da70b8bb0ba01eb0b999 to your computer and use it in GitHub Desktop.

Select an option

Save felipevelzani/3bd32fb16467da70b8bb0ba01eb0b999 to your computer and use it in GitHub Desktop.

Contributor Dashboard

A WordPress plugin for tracking contributor activity and visualizing engagement across progression ladders.

Architecture

The plugin uses a three-tier data model where each layer caches the computation of the previous:

Events (raw data)
    ↓ profile generation
Profiles (aggregated per-user)
    ↓ wpcd_profiles_generated action
Dashboard HTML (pre-rendered, cached)

Tier 1: Events

Raw activity records stored in wp_contributor_events. Each event has:

  • event_id — Unique identifier (for deduplication)
  • contributor_id — Username
  • event_type — Activity type
  • event_created_date — When it occurred

Events are immutable once imported. New event types are auto-created during import.

Tier 2: Profiles

Aggregated data per contributor in wp_contributor_profiles. Computed from events via WP-Cron batches:

  • Event counts by type
  • Current ladder stage
  • Activity status (active/warning/inactive)
  • Ladder journey history

Profile generation runs asynchronously. When complete, fires wpcd_profiles_generated.

Tier 3: Dashboard

The complete frontend HTML (including CSS) is pre-generated and stored in wp_options as a single cache entry (wpcd_dashboard_cache).

Cache is regenerated only when wpcd_profiles_generated fires. Frontend requests serve the cached HTML directly — no database queries on page load.

Status Thresholds

  • Active — Last activity within 30 days
  • Warning — Last activity 30-90 days ago
  • Inactive — No activity for 90+ days

Status is calculated during profile generation relative to the reference date (the newest event date), not "today". This handles delayed imports correctly in case we take more time to import new events.

Reference Date

All time-based calculations use wpcd_reference_date (stored in wp_options) instead of the current date. This is set automatically from MAX(event_created_date) when profile generation starts.

This ensures that if you import December events in January, the status calculations use December as "now", not January.

CSV Import Format

event_id,contributor_id,contributor_registered,event_type,event_date
987654321123,1234567,2024-01-15,support_reply,2024-06-20

This is the CSV format provided by Dion (Make/Meta), so using this as base for all importing.

Hooks

  • wpcd_profiles_generated — Fires after profile generation completes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment