from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from app.db.session import get_db
from app.api import deps
# ITT A JAVÍTÁS: A példányt importáljuk, nem a régi függvényeket
from app.services.social_service import social_service

router = APIRouter()

# Secured endpoint: Closed premium ecosystem
@router.get("/leaderboard")
async def read_leaderboard(
    limit: int = 10,
    db: AsyncSession = Depends(get_db),
    current_user = Depends(deps.get_current_user)
):
    return await social_service.get_leaderboard(db, limit)

# Secured endpoint: Closed premium ecosystem
@router.post("/vote/{provider_id}")
async def provider_vote(
    provider_id: int,
    vote_value: int,
    db: AsyncSession = Depends(get_db),
    current_user = Depends(deps.get_current_user)
):
    user_id = current_user.id
    return await social_service.vote_for_provider(db, user_id, provider_id, vote_value)