Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
<a href="#getting-started">Getting Started</a>
</p>

<p align="center">
<a href="https://github.com/SolFoundry/solfoundry/actions"><img src="https://img.shields.io/github/actions/workflow/status/SolFoundry/solfoundry/ci.yml?branch=main&label=Build" alt="Build Status"/></a>
<a href="https://github.com/SolFoundry/solfoundry/graphs/contributors"><img src="https://img.shields.io/github/contributors/SolFoundry/solfoundry?color=green" alt="Contributors"/></a>
<a href="https://github.com/SolFoundry/solfoundry/issues?q=is%3Aissue+is%3Aopen+label%3Abounty"><img src="https://img.shields.io/github/issues/SolFoundry/solfoundry/bounty?color=blue&label=Open%20Bounties" alt="Open Bounties"/></a>
<a href="https://solfoundry.org"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fapi.solfoundry.org%2Fapi%2Fstats%2Fshields%2Fpayouts&label=Paid&color=blueviolet" alt="Total $FNDRY Paid"/></a>
<a href="https://github.com/SolFoundry/solfoundry/blob/main/LICENSE"><img src="https://img.shields.io/github/license/SolFoundry/solfoundry" alt="License"/></a>
<br/>
<a href="https://github.com/SolFoundry/solfoundry/stargazers"><img src="https://img.shields.io/github/stars/SolFoundry/solfoundry?style=social" alt="Stars"/></a>
<a href="https://github.com/SolFoundry/solfoundry/network/members"><img src="https://img.shields.io/github/forks/SolFoundry/solfoundry?style=social" alt="Forks"/></a>
</p>

<p align="center">
<strong>$FNDRY Token (Solana)</strong><br/>
<code>C2TvY8E8B75EF2UP8cTpTp3EDUjTgjWmpaGnT74VBAGS</code><br/>
Expand Down
25 changes: 25 additions & 0 deletions backend/app/api/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Dict, Optional

from fastapi import APIRouter
from fastapi.responses import JSONResponse
from pydantic import BaseModel

from app.services.bounty_service import _bounty_store
Expand Down Expand Up @@ -154,3 +155,27 @@ async def get_stats() -> StatsResponse:
"""
data = _get_cached_stats()
return StatsResponse(**data)


@router.get("/api/stats/shields/payouts", response_class=JSONResponse)
async def get_payouts_shield():
"""Endpoint format specifically for shields.io custom badge endpoints.
Returns the total $FNDRY paid in a format compatible with shields.io JSON endpoint.
"""
data = _get_cached_stats()
total_paid = data.get("total_fndry_paid", 0)

# Format large numbers (e.g. 250000 -> 250k)
formatted_paid = f"{total_paid:,}"
if total_paid >= 1000000:
formatted_paid = f"{total_paid / 1000000:.1f}M"
elif total_paid >= 1000:
formatted_paid = f"{total_paid / 1000:.0f}k"

return {
"schemaVersion": 1,
"label": "Paid",
"message": f"{formatted_paid} $FNDRY",
"color": "blueviolet"
}

25 changes: 25 additions & 0 deletions backend/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Normal stats response
- Empty state (no bounties, no contributors)
- Cache behavior (returns cached data within TTL)
- Shields.io custom badge endpoints
"""

import pytest
Expand Down Expand Up @@ -179,3 +180,27 @@ def test_tier_breakdown(self, client, clear_stores):
assert data["bounties_by_tier"]["tier-2"]["completed"] == 0
assert data["bounties_by_tier"]["tier-3"]["open"] == 0
assert data["bounties_by_tier"]["tier-3"]["completed"] == 1

def test_shields_payouts_endpoint(self, client, clear_stores):
"""Test shields.io custom badge endpoint for payouts."""
from app.services.bounty_service import _bounty_store
from app.models.bounty import BountyDB

bounty1 = BountyDB(
id="bounty-1",
title="Test",
tier="tier-1",
reward_amount=250000,
status="completed",
submissions=[],
)
_bounty_store["bounty-1"] = bounty1

response = client.get("/api/stats/shields/payouts")
assert response.status_code == 200
data = response.json()

assert data["schemaVersion"] == 1
assert data["label"] == "Paid"
assert data["message"] == "250k $FNDRY"
assert data["color"] == "blueviolet"