feat: update language leaderboard calculation

This commit is contained in:
2024-08-09 21:45:14 +07:00
parent a5cd6383f3
commit 0142224f60
19 changed files with 330 additions and 59 deletions
+4
View File
@@ -8,6 +8,7 @@ const GITHUB_API_URL = "https://api.github.com";
const selectors = {
user: {
name: "h1.vcard-names > span.vcard-fullname",
avatar: ".js-profile-editable-replace img.avatar-user",
location: "li[itemprop='homeLocation'] span",
followers: ".js-profile-editable-area a[href$='?tab=followers'] > span",
following: ".js-profile-editable-area a[href$='?tab=following'] > span",
@@ -30,6 +31,8 @@ const github = {
const $ = cheerio.load(response);
const name = $(selectors.user.name).text().trim();
const avatar = $(selectors.user.avatar).attr("src");
console.log({ avatar });
const location = $(selectors.user.location).text().trim();
const followers = intval($(selectors.user.followers).text().trim());
const following = intval($(selectors.user.following).text().trim());
@@ -43,6 +46,7 @@ const github = {
return {
name: name || username,
avatar,
username,
location,
followers,
+3
View File
@@ -12,6 +12,9 @@ export const intval = (value: any) => {
export const getLanguageLogo = (language: string) => {
const alias: Record<string, string> = {
gdscript: "godot",
gap: "godot",
html: "html5",
css: "css3",
};
let lang = language.toLowerCase().replace(/[^a-zA-Z]/g, "");