dashboard

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package dashboard provides REST API handlers for the gamification dashboard. It exposes endpoints for leaderboards, user statistics, badges, and badge holders.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgeService

type BadgeService interface {
	GetUserBadges(ctx context.Context, userID uint) ([]models.UserBadge, error)
	GetBadgeCatalog(ctx context.Context) ([]models.Badge, error)
	GetBadgeByID(ctx context.Context, badgeID uint) (*models.Badge, error)
	GetBadgeHolders(ctx context.Context, badgeID uint) ([]models.User, error)
}

BadgeService interface for badge operations.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles dashboard API requests.

func NewHandler

func NewHandler(badgeService *badges.Service, leaderboardService *leaderboard.Service, log *logger.Logger) *Handler

NewHandler creates a new dashboard handler.

func NewHandlerWithInterfaces

func NewHandlerWithInterfaces(badgeService BadgeService, leaderboardService LeaderboardService, log *logger.Logger) *Handler

NewHandlerWithInterfaces creates a new dashboard handler with interface dependencies (useful for testing).

func (*Handler) GetBadgeByID

func (h *Handler) GetBadgeByID(c *gin.Context)

GetBadgeByID returns details for a specific badge. GET /api/v1/badges/:id.

func (*Handler) GetBadgeCatalog

func (h *Handler) GetBadgeCatalog(c *gin.Context)

GetBadgeCatalog returns all available badges with holder counts. GET /api/v1/badges.

func (*Handler) GetBadgeHolders

func (h *Handler) GetBadgeHolders(c *gin.Context)

GetBadgeHolders returns users who have earned a specific badge. GET /api/v1/badges/:id/holders?limit=50.

func (*Handler) GetGlobalLeaderboard

func (h *Handler) GetGlobalLeaderboard(c *gin.Context)

GetGlobalLeaderboard returns the global leaderboard. GET /api/v1/leaderboard?period=month&metric=completed_reviews&limit=10.

func (*Handler) GetTeamLeaderboard

func (h *Handler) GetTeamLeaderboard(c *gin.Context)

GetTeamLeaderboard returns the leaderboard for a specific team. GET /api/v1/leaderboard/:team?period=month&metric=completed_reviews&limit=10.

func (*Handler) GetUserBadges

func (h *Handler) GetUserBadges(c *gin.Context)

GetUserBadges returns badges earned by a specific user. GET /api/v1/users/:id/badges.

func (*Handler) GetUserStats

func (h *Handler) GetUserStats(c *gin.Context)

GetUserStats returns statistics for a specific user. GET /api/v1/users/:id/stats?period=month.

type LeaderboardService

type LeaderboardService interface {
	GetGlobalLeaderboard(ctx context.Context, period, metric string, limit int) ([]leaderboard.Entry, error)
	GetTeamLeaderboard(ctx context.Context, team, period, metric string, limit int) ([]leaderboard.Entry, error)
	GetUserStats(ctx context.Context, userID uint, period string) (*leaderboard.UserStats, error)
}

LeaderboardService interface for leaderboard operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL