Skip to content

pdiomede/subgraph-network-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Network Subgraph Metrics Dashboard

This Python project generates a dashboard and CSV report that show how many subgraphs are deployed per network on The Graph Network. It includes time-based metrics, daily snapshots, and a modern, responsive HTML interface.

Live Dashboard:
🔗 graphtools.pro/network

🧪 This dashboard is part of Graph Tools Pro, a community-driven initiative to provide useful, independent analytics tools for The Graph ecosystem.


📊 Features

  • Daily fetch of subgraph counts per network
  • HTML dashboard with light/dark theme
  • # rank counter column showing each chain's position
  • Top-20 default view with a "Show All / Show Less" toggle button
  • Sortable columns — clicking any column header re-sorts and renumbers the rank column
  • CSV export of all network counts
  • 24-hour delta tracking (if yesterday's snapshot exists)
  • Custom network logos
  • JSON snapshot stored daily with timestamp and counts
  • Full logs of script runs

📂 Project Structure

📦 network/
├── 📜 fetch_network_metrics.py        # Main script
├── 📜 .env                            # Environment variables (not tracked)
├── 📂 logs/                           # Timestamped log files
└── 📂 reports/
    ├── 📜 index.html                  # Rendered dashboard
    ├── 📜 network_subgraph_counts.csv # CSV report
    ├── 📂 images/                     # Network logos + social card
    │   └── 📜 social-card.png         # OG/Twitter share image (1200×630)
    └── 📂 metrics/                    # JSON metric snapshots per day

🚀 How to Run

  1. Install dependencies:
pip install requests python-dotenv
  1. Create a .env file:
GRAPH_API_KEY=your_graph_api_key
  1. Run the script:
python fetch_network_metrics.py
  1. Open reports/index.html in your browser to view the dashboard.

📋 Changelog

v1.2.2 — Mar 2026

Bug fixes (10 issues resolved):

  • Unhandled network exceptionsrequests.post() now wrapped in try/except; connection errors and timeouts are logged and return an empty result instead of crashing
  • Unhandled JSONDecodeErrorresponse.json() now guarded; non-JSON gateway responses (e.g. HTML error pages) are caught and logged
  • Partial data on HTTP error — HTTP non-200 now returns [] instead of silently returning however many rows had been fetched before the failure
  • total_subgraphs_yesterday inconsistent state — both total_subgraphs_yesterday and yesterday_network_counts are now reset to None in the except block
  • Zero baseline treated as valid delta — a missing total_subgraphs key in yesterday's snapshot no longer produces a misleading "all subgraphs gained" delta; 0 is now treated as None
  • Timestamp computed at import timetimestamp is now computed inside save_subgraph_counts_to_html() so the HTML reflects the actual write time, not script-start time
  • Network logo outside anchor tag — the network logo <img> was before the <a>, so clicking it did nothing; it is now inside the anchor
  • Sort comparator broken for equal values? 1 : -1 always returned -1 for ties, producing unstable ordering; replaced with aVal - bVal (numeric) and localeCompare (text)
  • log_file undefined when API key guard fires — directory and log-file setup now runs before the GRAPH_API_KEY check, so the error can be logged properly
  • HTTP errors logged without detail — error log now includes the HTTP status code and the first 500 chars of the response body

v1.2.1 — Mar 2026

  • Version bump; all v1.1.0 features and fixes consolidated into a stable release

v1.1.0 — Mar 2026

  • Added # rank counter column (first column in the table)
  • Default view shows only the top 20 chains; a Show All / Show Less button reveals the full list
  • Sorting any column now renumbers the # column and reapplies the top-20 visibility
  • Footer now spans the full window width with no word wrap
  • Updated footer to flex-row layout with version string and GitHub SVG icon
  • Added dedicated social card image (social-card.png, 1200×630) wired into all OG/X meta tags
  • Added METRIC_SNAPSHOT_MINUTE env var — schedule time now displays as 6:30am instead of 6am
  • Removed version string from the "Generated on" subtitle
  • Fixed and expanded social card meta tags (Open Graph + X/Twitter) for correct sharing on all platforms
  • Removed stale old.py and untracked .DS_Store files from the repo

Bug fixes:

  • Added GRAPH_API_KEY guard — script now raises a clear error instead of silently embedding None in the API URL
  • Fixed wrong logo for Sonic network (was incorrectly using abstract.png)
  • Removed dead SUBGRAPH_URL constant and unused NetworkSubgraphCount dataclass + import
  • Fixed JS TypeError on page load — getElementById('themeToggle') returned null; added null guard
  • Fixed isNumeric in sortTable — Var (24h) column was excluded from numeric sort
  • Fixed hardcoded 7am in the HTML subtitle — now correctly reads from METRIC_SNAPSHOT_HOUR
  • Synced Python template with manually added # column header and show-all CSS/JS so the next script run no longer wipes those features
  • Fixed loose JS comparison != → strict !==

v1.0.5 — May 2025

  • Initial public release with per-network subgraph counts, 24h delta, unique indexers, light/dark theme, CSV export, and daily JSON snapshots

📊 Powered By

  • 🧠 The Graph
  • 🧩 Python 3.x, HTML5 + CSS
  • ⚙️ Data sorting and light/dark theming via vanilla JavaScript