diff --git a/src/trophy.ts b/src/trophy.ts index 778f30d..24dc708 100644 --- a/src/trophy.ts +++ b/src/trophy.ts @@ -267,6 +267,57 @@ export class TotalReviewsTrophy extends Trophy { } } +export class AccountDurationTrophy extends Trophy { + constructor(score: number) { + const rankConditions = [ + new RankCondition( + RANK.SSS, + "Seasoned Veteran", + 70, // 20 years + ), + new RankCondition( + RANK.SS, + "GranMaster", + 55, // 15 years + ), + new RankCondition( + RANK.S, + "Master Dev", + 40, // 10 years + ), + new RankCondition( + RANK.AAA, + "Expert Dev", + 28, // 7.5 years + ), + new RankCondition( + RANK.AA, + "Experienced Dev", + 18, // 5 years + ), + new RankCondition( + RANK.A, + "Intermediate Dev", + 11, // 3 years + ), + new RankCondition( + RANK.B, + "Junior Dev", + 6, // 1.5 years + ), + new RankCondition( + RANK.C, + "Newbie", + 2, // 0.5 year + ), + ]; + super(score, rankConditions); + this.title = "Experience"; + this.filterTitles = ["Experience", "Duration", "Since"]; + // this.hidden = true; + } +} + export class TotalStarTrophy extends Trophy { constructor(score: number) { const rankConditions = [ diff --git a/src/trophy_list.ts b/src/trophy_list.ts index d8e406f..2fcab4c 100644 --- a/src/trophy_list.ts +++ b/src/trophy_list.ts @@ -1,4 +1,5 @@ import { + AccountDurationTrophy, AllSuperRankTrophy, AncientAccountTrophy, Joined2020Trophy, @@ -40,6 +41,7 @@ export class TrophyList { new OGAccountTrophy(userInfo.ogAccount), new Joined2020Trophy(userInfo.joined2020), new MultipleOrganizationsTrophy(userInfo.totalOrganizations), + new AccountDurationTrophy(userInfo.durationDays), ); } get length() { diff --git a/src/user_info.ts b/src/user_info.ts index 7bfdac8..805402d 100644 --- a/src/user_info.ts +++ b/src/user_info.ts @@ -51,6 +51,7 @@ export class UserInfo { public readonly totalRepositories: number; public readonly languageCount: number; public readonly durationYear: number; + public readonly durationDays: number; public readonly ancientAccount: number; public readonly joined2020: number; public readonly ogAccount: number; @@ -83,6 +84,9 @@ export class UserInfo { const durationTime = new Date().getTime() - new Date(userActivity.createdAt).getTime(); const durationYear = new Date(durationTime).getUTCFullYear() - 1970; + const durationDays = Math.floor( + durationTime / (1000 * 60 * 60 * 24) / 100, + ); const ancientAccount = new Date(userActivity.createdAt).getFullYear() <= 2010 ? 1 : 0; const joined2020 = new Date(userActivity.createdAt).getFullYear() == 2020 @@ -104,6 +108,7 @@ export class UserInfo { this.totalRepositories = userRepository.repositories.totalCount; this.languageCount = languages.size; this.durationYear = durationYear; + this.durationDays = durationDays; this.ancientAccount = ancientAccount; this.joined2020 = joined2020; this.ogAccount = ogAccount;