Spaces:
Configuration error
Configuration error
| /** | |
| * Creator Rank System | |
| * Ranks are based on prompt performance metrics | |
| */ | |
| export type CreatorRank = 'newcomer' | 'bronze' | 'silver' | 'gold' | 'verified' | |
| export interface CreatorRankInfo { | |
| rank: CreatorRank | |
| name: string | |
| color: string | |
| bgColor: string | |
| icon: string | |
| minPrompts: number | |
| minRuns: number | |
| minStars: number | |
| description: string | |
| } | |
| export const CREATOR_RANKS: Record<CreatorRank, CreatorRankInfo> = { | |
| newcomer: { | |
| rank: 'newcomer', | |
| name: 'Newcomer', | |
| color: 'text-gray-500', | |
| bgColor: 'bg-gray-100 dark:bg-gray-800', | |
| icon: 'π±', | |
| minPrompts: 0, | |
| minRuns: 0, | |
| minStars: 0, | |
| description: 'Just getting started' | |
| }, | |
| bronze: { | |
| rank: 'bronze', | |
| name: 'Bronze Creator', | |
| color: 'text-amber-700', | |
| bgColor: 'bg-amber-100 dark:bg-amber-900/30', | |
| icon: 'π₯', | |
| minPrompts: 3, | |
| minRuns: 50, | |
| minStars: 5, | |
| description: 'Building a collection' | |
| }, | |
| silver: { | |
| rank: 'silver', | |
| name: 'Silver Creator', | |
| color: 'text-gray-400', | |
| bgColor: 'bg-gray-100 dark:bg-gray-700', | |
| icon: 'π₯', | |
| minPrompts: 10, | |
| minRuns: 500, | |
| minStars: 25, | |
| description: 'Growing influence' | |
| }, | |
| gold: { | |
| rank: 'gold', | |
| name: 'Gold Creator', | |
| color: 'text-yellow-500', | |
| bgColor: 'bg-yellow-100 dark:bg-yellow-900/30', | |
| icon: 'π₯', | |
| minPrompts: 25, | |
| minRuns: 2500, | |
| minStars: 100, | |
| description: 'Top tier creator' | |
| }, | |
| verified: { | |
| rank: 'verified', | |
| name: 'Verified Creator', | |
| color: 'text-blue-500', | |
| bgColor: 'bg-blue-100 dark:bg-blue-900/30', | |
| icon: 'β', | |
| minPrompts: 50, | |
| minRuns: 10000, | |
| minStars: 500, | |
| description: 'Elite verified creator' | |
| } | |
| } | |
| /** | |
| * Calculate creator rank based on their stats | |
| */ | |
| export function calculateCreatorRank(stats: { | |
| promptCount: number | |
| totalRuns: number | |
| totalStars: number | |
| }): CreatorRankInfo { | |
| const { promptCount, totalRuns, totalStars } = stats | |
| // Check ranks from highest to lowest | |
| if ( | |
| promptCount >= CREATOR_RANKS.verified.minPrompts && | |
| totalRuns >= CREATOR_RANKS.verified.minRuns && | |
| totalStars >= CREATOR_RANKS.verified.minStars | |
| ) { | |
| return CREATOR_RANKS.verified | |
| } | |
| if ( | |
| promptCount >= CREATOR_RANKS.gold.minPrompts && | |
| totalRuns >= CREATOR_RANKS.gold.minRuns && | |
| totalStars >= CREATOR_RANKS.gold.minStars | |
| ) { | |
| return CREATOR_RANKS.gold | |
| } | |
| if ( | |
| promptCount >= CREATOR_RANKS.silver.minPrompts && | |
| totalRuns >= CREATOR_RANKS.silver.minRuns && | |
| totalStars >= CREATOR_RANKS.silver.minStars | |
| ) { | |
| return CREATOR_RANKS.silver | |
| } | |
| if ( | |
| promptCount >= CREATOR_RANKS.bronze.minPrompts && | |
| totalRuns >= CREATOR_RANKS.bronze.minRuns && | |
| totalStars >= CREATOR_RANKS.bronze.minStars | |
| ) { | |
| return CREATOR_RANKS.bronze | |
| } | |
| return CREATOR_RANKS.newcomer | |
| } | |
| /** | |
| * Get progress towards next rank | |
| */ | |
| export function getRankProgress(stats: { | |
| promptCount: number | |
| totalRuns: number | |
| totalStars: number | |
| }): { | |
| currentRank: CreatorRankInfo | |
| nextRank: CreatorRankInfo | null | |
| progress: { | |
| prompts: { current: number; required: number; percent: number } | |
| runs: { current: number; required: number; percent: number } | |
| stars: { current: number; required: number; percent: number } | |
| } | |
| } { | |
| const currentRank = calculateCreatorRank(stats) | |
| // Get next rank | |
| const rankOrder: CreatorRank[] = ['newcomer', 'bronze', 'silver', 'gold', 'verified'] | |
| const currentIndex = rankOrder.indexOf(currentRank.rank) | |
| const nextRank = currentIndex < rankOrder.length - 1 | |
| ? CREATOR_RANKS[rankOrder[currentIndex + 1]] | |
| : null | |
| if (!nextRank) { | |
| return { | |
| currentRank, | |
| nextRank: null, | |
| progress: { | |
| prompts: { current: stats.promptCount, required: 0, percent: 100 }, | |
| runs: { current: stats.totalRuns, required: 0, percent: 100 }, | |
| stars: { current: stats.totalStars, required: 0, percent: 100 } | |
| } | |
| } | |
| } | |
| return { | |
| currentRank, | |
| nextRank, | |
| progress: { | |
| prompts: { | |
| current: stats.promptCount, | |
| required: nextRank.minPrompts, | |
| percent: Math.min((stats.promptCount / nextRank.minPrompts) * 100, 100) | |
| }, | |
| runs: { | |
| current: stats.totalRuns, | |
| required: nextRank.minRuns, | |
| percent: Math.min((stats.totalRuns / nextRank.minRuns) * 100, 100) | |
| }, | |
| stars: { | |
| current: stats.totalStars, | |
| required: nextRank.minStars, | |
| percent: Math.min((stats.totalStars / nextRank.minStars) * 100, 100) | |
| } | |
| } | |
| } | |
| } | |