export type RankingCategoryId =
  | 'weekly_commits'
  | 'night_owl'
  | 'popularity'
  | 'productive'
  | 'social'
  | 'rising'
  | 'comprehensive';

export interface DatawhaleMemberRow {
  id?: string;
  name?: string;
  github?: string;
  domain?: string;
  primary_domain?: string;
  public_repos?: number;
  total_stars?: number;
  followers?: number;
  followers_count?: number;
  following?: number;
  org_repos_count?: number;
  org_total_stars?: number;
  org_total_contributions?: number;
  avatar?: string;
  location?: string;
  company?: string;
}

export interface DatawhaleCommitStats {
  total_commits?: number;
  repo_count?: number;
  active_days?: number;
  avg_commits_per_day?: number;
  night_owl_commits?: number;
  night_owl_percentage?: number;
}

export interface DatawhaleWeeklyCommitsPayload {
  update_time?: string;
  days_range?: number;
  total_commits?: number;
  user_commits?: Record<string, DatawhaleCommitStats>;
}

export interface RankingCategory {
  id: RankingCategoryId;
  label: string;
  title: string;
  description: string;
  icon: string;
}

export interface RankingUser {
  id: string;
  name: string;
  avatarText: string;
  avatarUrl: string;
  githubUrl: string;
  domain: string;
  domains: string[];
  location: string;
  score: number;
  scoreLabel: string;
  contrib: number;
  answers: number;
  likes: number;
  reward: number;
}

export interface RankingEntry extends RankingUser {
  rank: number;
}

export interface DatawhaleHonorRankingPayload {
  source: 'datawhale-members-visualization';
  activeCategory: RankingCategoryId;
  categories: RankingCategory[];
  topRankers: RankingEntry[];
  rankers: RankingEntry[];
  myRank: {
    rank: number | null;
    score: number;
    reward: number;
  };
  total: number;
  syncedAt: string | null;
  sourceUpdatedAt: string | null;
}
