/**
 * @copyright 2026 NHCarrigan
 * @license Naomi's Public License
 * @author Naomi Carrigan
 */

import { Injectable, inject } from '@angular/core';
import { Observable } from 'rxjs';
import type {
  LeaderboardResponse,
  SuggestionsLeaderboard,
  LikesLeaderboard,
  CommentsLeaderboard,
  OverallLeaderboard,
} from '@library/shared-types';
import { ApiService } from './api.service';

@Injectable({
  providedIn: 'root'
})
export class LeaderboardService {
  private apiService = inject(ApiService);

  /**
   * Get all leaderboards at once.
   */
  getAllLeaderboards(limit = 25): Observable<LeaderboardResponse> {
    return this.apiService.get<LeaderboardResponse>(`/leaderboard?limit=${limit}`);
  }

  /**
   * Get top users by suggestions.
   */
  getTopSuggestions(limit = 25): Observable<SuggestionsLeaderboard[]> {
    return this.apiService.get<SuggestionsLeaderboard[]>(`/leaderboard/suggestions?limit=${limit}`);
  }

  /**
   * Get top users by likes.
   */
  getTopLikes(limit = 25): Observable<LikesLeaderboard[]> {
    return this.apiService.get<LikesLeaderboard[]>(`/leaderboard/likes?limit=${limit}`);
  }

  /**
   * Get top users by comments.
   */
  getTopComments(limit = 25): Observable<CommentsLeaderboard[]> {
    return this.apiService.get<CommentsLeaderboard[]>(`/leaderboard/comments?limit=${limit}`);
  }

  /**
   * Get overall leaderboard.
   */
  getOverallLeaderboard(limit = 25): Observable<OverallLeaderboard[]> {
    return this.apiService.get<OverallLeaderboard[]>(`/leaderboard/overall?limit=${limit}`);
  }
}
