mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Replace Number to number
This commit is contained in:
parent
e17cfb9bb4
commit
52ccc94bb6
2 changed files with 49 additions and 70 deletions
|
|
@ -1,13 +1,13 @@
|
||||||
import {soxa} from "../deps.ts";
|
import {soxa} from "../deps.ts";
|
||||||
export class UserInfo {
|
export class UserInfo {
|
||||||
constructor(
|
constructor(
|
||||||
public totalCommits: Number,
|
public totalCommits: number,
|
||||||
public totalFollowers: Number,
|
public totalFollowers: number,
|
||||||
public totalIssues: Number,
|
public totalIssues: number,
|
||||||
public totalPullRequests: Number,
|
public totalPullRequests: number,
|
||||||
public totalStargazers: Number,
|
public totalStargazers: number,
|
||||||
public totalRepositories: Number,
|
public totalRepositories: number,
|
||||||
public totalContributed: Number,
|
public totalContributed: number,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +60,7 @@ export class GithubAPIClient {
|
||||||
);
|
);
|
||||||
const userData = response.data.data.user;
|
const userData = response.data.data.user;
|
||||||
const totalCommits = userData.contributionsCollection.restrictedContributionsCount + userData.contributionsCollection.totalCommitContributions;
|
const totalCommits = userData.contributionsCollection.restrictedContributionsCount + userData.contributionsCollection.totalCommitContributions;
|
||||||
const totalStargazers = userData.repositories.nodes.reduce((prev: Number, node: any) => {
|
const totalStargazers = userData.repositories.nodes.reduce((prev: number, node: any) => {
|
||||||
return prev + node.stargazers.totalCount;
|
return prev + node.stargazers.totalCount;
|
||||||
}, 0);
|
}, 0);
|
||||||
const userInfo = new UserInfo(
|
const userInfo = new UserInfo(
|
||||||
|
|
|
||||||
103
src/trophies.ts
103
src/trophies.ts
|
|
@ -1,11 +1,14 @@
|
||||||
import { getTropyIcon } from "./icons.ts";
|
import { getTropyIcon } from "./icons.ts";
|
||||||
import { CONSTANTS, RANK } from "./utils.ts";
|
import { CONSTANTS, RANK, abridgeScore } from "./utils.ts";
|
||||||
|
|
||||||
export abstract class Trophy {
|
export abstract class Trophy {
|
||||||
rank: RANK = RANK.UNKNOWN;
|
rank: RANK = RANK.UNKNOWN;
|
||||||
topMessage = "Unknown";
|
topMessage = "Unknown";
|
||||||
bottomMessage = "+0";
|
bottomMessage = "+0";
|
||||||
title = "";
|
title = "";
|
||||||
|
constructor() {
|
||||||
|
this.setRank();
|
||||||
|
}
|
||||||
abstract setRank(): void;
|
abstract setRank(): void;
|
||||||
render(x = 0, y = 0, panelSize = CONSTANTS.DEFALT_PANEL_SIZE): string {
|
render(x = 0, y = 0, panelSize = CONSTANTS.DEFALT_PANEL_SIZE): string {
|
||||||
return `
|
return `
|
||||||
|
|
@ -31,169 +34,145 @@ export abstract class Trophy {
|
||||||
${getTropyIcon(this.rank)}
|
${getTropyIcon(this.rank)}
|
||||||
<text x="50%" y="18" text-anchor="middle" font-family="Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;" font-weight="bold" font-size="12" fill="#000">${this.title}</text>
|
<text x="50%" y="18" text-anchor="middle" font-family="Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;" font-weight="bold" font-size="12" fill="#000">${this.title}</text>
|
||||||
<text x="50%" y="85" text-anchor="middle" font-family="Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;" font-weight="bold" font-size="9.5" fill="#666">${this.topMessage}</text>
|
<text x="50%" y="85" text-anchor="middle" font-family="Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;" font-weight="bold" font-size="9.5" fill="#666">${this.topMessage}</text>
|
||||||
<text x="50%" y="97" text-anchor="middle" font-family="Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;" font-weight="bold" font-size="9" fill="#666">${this.bottomMessage}</text>
|
<text x="50%" y="99" text-anchor="middle" font-family="Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;" font-weight="bold" font-size="9" fill="#666">${this.bottomMessage}</text>
|
||||||
</svg>
|
</svg>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TotalStarTrophy extends Trophy {
|
export class TotalStarTrophy extends Trophy {
|
||||||
constructor(private totalStartgazer: Number) {
|
constructor(private score: number) {
|
||||||
super();
|
super();
|
||||||
this.title = "Star";
|
this.title = "Star";
|
||||||
this.setRank();
|
|
||||||
}
|
}
|
||||||
setRank() {
|
setRank() {
|
||||||
if (this.totalStartgazer >= 200) {
|
this.bottomMessage = abridgeScore(this.score);
|
||||||
|
if (this.score >= 200) {
|
||||||
this.rank = RANK.S;
|
this.rank = RANK.S;
|
||||||
this.topMessage = "Super Star";
|
this.topMessage = "Super Star";
|
||||||
this.bottomMessage = "+200";
|
} else if (this.score >= 100) {
|
||||||
} else if (this.totalStartgazer >= 100) {
|
|
||||||
this.rank = RANK.A;
|
this.rank = RANK.A;
|
||||||
this.topMessage = "High Star";
|
this.topMessage = "High Star";
|
||||||
this.bottomMessage = "+100";
|
} else if (this.score >= 10) {
|
||||||
} else if (this.totalStartgazer >= 10) {
|
|
||||||
this.rank = RANK.B;
|
this.rank = RANK.B;
|
||||||
this.topMessage = "Middle Star";
|
this.topMessage = "Middle Star";
|
||||||
this.bottomMessage = "+10";
|
} else if (this.score >= 1) {
|
||||||
} else if (this.totalStartgazer >= 1) {
|
|
||||||
this.rank = RANK.C;
|
this.rank = RANK.C;
|
||||||
this.topMessage = "First Star";
|
this.topMessage = "First Star";
|
||||||
this.bottomMessage = "+1";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TotalCommitTrophy extends Trophy {
|
export class TotalCommitTrophy extends Trophy {
|
||||||
constructor(private totalStartgazer: Number) {
|
constructor(private score: number) {
|
||||||
super();
|
super();
|
||||||
this.title = "Commit";
|
this.title = "Commit";
|
||||||
this.setRank();
|
|
||||||
}
|
}
|
||||||
setRank() {
|
setRank() {
|
||||||
if (this.totalStartgazer >= 1000) {
|
this.bottomMessage = abridgeScore(this.score);
|
||||||
|
if (this.score >= 1000) {
|
||||||
this.rank = RANK.S;
|
this.rank = RANK.S;
|
||||||
this.topMessage = "Super Commiter";
|
this.topMessage = "Super Commiter";
|
||||||
this.bottomMessage = "+1000";
|
} else if (this.score >= 500) {
|
||||||
} else if (this.totalStartgazer >= 500) {
|
|
||||||
this.rank = RANK.A;
|
this.rank = RANK.A;
|
||||||
this.topMessage = "High Commiter";
|
this.topMessage = "High Commiter";
|
||||||
this.bottomMessage = "+500";
|
} else if (this.score >= 100) {
|
||||||
} else if (this.totalStartgazer >= 100) {
|
|
||||||
this.rank = RANK.B;
|
this.rank = RANK.B;
|
||||||
this.topMessage = "Middle Commiter";
|
this.topMessage = "Middle Commiter";
|
||||||
this.bottomMessage = "+100";
|
} else if (this.score >= 1) {
|
||||||
} else if (this.totalStartgazer >= 1) {
|
|
||||||
this.rank = RANK.C;
|
this.rank = RANK.C;
|
||||||
this.topMessage = "First Commit";
|
this.topMessage = "First Commit";
|
||||||
this.bottomMessage = "+1";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TotalFollowerTrophy extends Trophy {
|
export class TotalFollowerTrophy extends Trophy {
|
||||||
constructor(private totalStartgazer: Number) {
|
constructor(private score: number) {
|
||||||
super();
|
super();
|
||||||
this.title = "Follower";
|
this.title = "Follower";
|
||||||
this.setRank();
|
|
||||||
}
|
}
|
||||||
setRank() {
|
setRank() {
|
||||||
if (this.totalStartgazer >= 100) {
|
this.bottomMessage = abridgeScore(this.score);
|
||||||
|
if (this.score >= 100) {
|
||||||
this.rank = RANK.S;
|
this.rank = RANK.S;
|
||||||
this.topMessage = "Celebrity";
|
this.topMessage = "Celebrity";
|
||||||
this.bottomMessage = "+100";
|
} else if (this.score >= 20) {
|
||||||
} else if (this.totalStartgazer >= 20) {
|
|
||||||
this.rank = RANK.A;
|
this.rank = RANK.A;
|
||||||
this.topMessage = "Famous User";
|
this.topMessage = "Famous User";
|
||||||
this.bottomMessage = "+20";
|
} else if (this.score >= 10) {
|
||||||
} else if (this.totalStartgazer >= 10) {
|
|
||||||
this.rank = RANK.B;
|
this.rank = RANK.B;
|
||||||
this.topMessage = "Many Friends";
|
this.topMessage = "Many Friends";
|
||||||
this.bottomMessage = "+10";
|
} else if (this.score >= 1) {
|
||||||
} else if (this.totalStartgazer >= 1) {
|
|
||||||
this.rank = RANK.C;
|
this.rank = RANK.C;
|
||||||
this.topMessage = "First Friend";
|
this.topMessage = "First Friend";
|
||||||
this.bottomMessage = "+1";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class TotalIssueTrophy extends Trophy {
|
export class TotalIssueTrophy extends Trophy {
|
||||||
constructor(private totalStartgazer: Number) {
|
constructor(private score: number) {
|
||||||
super();
|
super();
|
||||||
this.title = "Issue";
|
this.title = "Issue";
|
||||||
this.setRank();
|
|
||||||
}
|
}
|
||||||
setRank() {
|
setRank() {
|
||||||
if (this.totalStartgazer >= 100) {
|
this.bottomMessage = abridgeScore(this.score);
|
||||||
|
if (this.score >= 100) {
|
||||||
this.rank = RANK.S;
|
this.rank = RANK.S;
|
||||||
this.topMessage = "Super Issuer";
|
this.topMessage = "Super Issuer";
|
||||||
this.bottomMessage = "+100";
|
} else if (this.score >= 20) {
|
||||||
} else if (this.totalStartgazer >= 20) {
|
|
||||||
this.rank = RANK.A;
|
this.rank = RANK.A;
|
||||||
this.topMessage = "High Issuer";
|
this.topMessage = "High Issuer";
|
||||||
this.bottomMessage = "+20";
|
} else if (this.score >= 10) {
|
||||||
} else if (this.totalStartgazer >= 10) {
|
|
||||||
this.rank = RANK.B;
|
this.rank = RANK.B;
|
||||||
this.topMessage = "Middle Issuer";
|
this.topMessage = "Middle Issuer";
|
||||||
this.bottomMessage = "+10";
|
} else if (this.score >= 1) {
|
||||||
} else if (this.totalStartgazer >= 1) {
|
|
||||||
this.rank = RANK.C;
|
this.rank = RANK.C;
|
||||||
this.topMessage = "First Issue";
|
this.topMessage = "First Issue";
|
||||||
this.bottomMessage = "+1";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TotalPullRequestTrophy extends Trophy {
|
export class TotalPullRequestTrophy extends Trophy {
|
||||||
constructor(private totalStartgazer: Number) {
|
constructor(private score: number) {
|
||||||
super();
|
super();
|
||||||
this.title = "PR";
|
this.title = "PR";
|
||||||
this.setRank();
|
|
||||||
}
|
}
|
||||||
setRank() {
|
setRank() {
|
||||||
if (this.totalStartgazer >= 100) {
|
this.bottomMessage = abridgeScore(this.score);
|
||||||
|
if (this.score >= 100) {
|
||||||
this.rank = RANK.S;
|
this.rank = RANK.S;
|
||||||
this.topMessage = "God PR User";
|
this.topMessage = "God PR User";
|
||||||
this.bottomMessage = "+100";
|
} else if (this.score >= 20) {
|
||||||
} else if (this.totalStartgazer >= 20) {
|
|
||||||
this.rank = RANK.A;
|
this.rank = RANK.A;
|
||||||
this.topMessage = "High PR User";
|
this.topMessage = "High PR User";
|
||||||
this.bottomMessage = "+20";
|
} else if (this.score >= 10) {
|
||||||
} else if (this.totalStartgazer >= 10) {
|
|
||||||
this.rank = RANK.B;
|
this.rank = RANK.B;
|
||||||
this.topMessage = "Many PRs";
|
this.topMessage = "Many PRs";
|
||||||
this.bottomMessage = "+10";
|
} else if (this.score >= 1) {
|
||||||
} else if (this.totalStartgazer >= 1) {
|
|
||||||
this.rank = RANK.C;
|
this.rank = RANK.C;
|
||||||
this.topMessage = "First PR";
|
this.topMessage = "First PR";
|
||||||
this.bottomMessage = "+1";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TotalRepositoryTrophy extends Trophy {
|
export class TotalRepositoryTrophy extends Trophy {
|
||||||
constructor(private totalStartgazer: Number) {
|
constructor(private score: number) {
|
||||||
super();
|
super();
|
||||||
this.title = "Repo";
|
this.title = "Repo";
|
||||||
this.setRank();
|
|
||||||
}
|
}
|
||||||
setRank() {
|
setRank() {
|
||||||
if (this.totalStartgazer >= 100) {
|
this.bottomMessage = abridgeScore(this.score);
|
||||||
|
if (this.score >= 100) {
|
||||||
this.rank = RANK.S;
|
this.rank = RANK.S;
|
||||||
this.topMessage = "God Repo Creator";
|
this.topMessage = "God Repo Creator";
|
||||||
this.bottomMessage = "+100";
|
} else if (this.score >= 20) {
|
||||||
} else if (this.totalStartgazer >= 20) {
|
|
||||||
this.rank = RANK.A;
|
this.rank = RANK.A;
|
||||||
this.topMessage = "High Repo Creator";
|
this.topMessage = "High Repo Creator";
|
||||||
this.bottomMessage = "+20";
|
} else if (this.score >= 10) {
|
||||||
} else if (this.totalStartgazer >= 10) {
|
|
||||||
this.rank = RANK.B;
|
this.rank = RANK.B;
|
||||||
this.topMessage = "Many Repo";
|
this.topMessage = "Many Repo";
|
||||||
this.bottomMessage = "+10";
|
} else if (this.score >= 1) {
|
||||||
} else if (this.totalStartgazer >= 1) {
|
|
||||||
this.rank = RANK.C;
|
this.rank = RANK.C;
|
||||||
this.topMessage = "First Repository";
|
this.topMessage = "First Repository";
|
||||||
this.bottomMessage = "+1";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue