diff --git a/src/card.ts b/src/card.ts index 4e13e10..c0a67d2 100644 --- a/src/card.ts +++ b/src/card.ts @@ -11,6 +11,7 @@ import { AncientAccountTrophy, Joined2020Trophy, AllSuperRankTrophy, + MultipleOrganizationsTrophy, } from "./trophies.ts"; import { UserInfo } from "./user_info.ts"; import { RANK_ORDER, RANK } from "./utils.ts"; @@ -54,6 +55,7 @@ export class Card { new AncientAccountTrophy(userInfo.ancientAccount), new Joined2020Trophy(userInfo.joined2020), new AllSuperRankTrophy(isAllSRank), + new MultipleOrganizationsTrophy(userInfo.totalOrganizations), ); // Filter by hidden diff --git a/src/github_api_client.ts b/src/github_api_client.ts index d6734b8..ff7b46b 100644 --- a/src/github_api_client.ts +++ b/src/github_api_client.ts @@ -22,6 +22,9 @@ export class GithubAPIClient { issues(first: 1) { totalCount } + organizations(first: 1) { + totalCount + } followers(first: 1) { totalCount } diff --git a/src/trophies.ts b/src/trophies.ts index f8d0f96..6e7a4c1 100644 --- a/src/trophies.ts +++ b/src/trophies.ts @@ -182,6 +182,21 @@ export class LongTimeAccountTrophy extends Trophy{ this.hidden = true; } } +export class MultipleOrganizationsTrophy extends Trophy{ + constructor(score: number){ + const rankConditions = [ + new RankCondition( + RANK.SECRET, + "Multiple Jobs", + 2, + ), + ]; + super(score, rankConditions); + this.title = "Organizations"; + this.filterTitles = ["Organizations"]; + this.hidden = true; + } +} export class TotalStarTrophy extends Trophy { constructor(score: number) { diff --git a/src/user_info.ts b/src/user_info.ts index 17e8a0c..23253c7 100644 --- a/src/user_info.ts +++ b/src/user_info.ts @@ -16,6 +16,9 @@ export type GitHubUserData = { issues: { totalCount: number; }; + organizations: { + totalCount: number; + }; followers: { totalCount: number; }; @@ -28,6 +31,7 @@ export class UserInfo { public readonly totalCommits: number; public readonly totalFollowers: number; public readonly totalIssues: number; + public readonly totalOrganizations: number; public readonly totalPullRequests: number; public readonly totalStargazers: number; public readonly totalRepositories: number; @@ -70,6 +74,7 @@ export class UserInfo { this.totalCommits = totalCommits; this.totalFollowers = userData.followers.totalCount; this.totalIssues = userData.issues.totalCount; + this.totalOrganizations = userData.organizations.totalCount; this.totalPullRequests = userData.pullRequests.totalCount; this.totalStargazers = totalStargazers; this.totalRepositories = userData.repositories.totalCount;