feat: add leaderboard category

This commit is contained in:
2024-08-09 20:33:07 +07:00
parent e8ed08d49b
commit a5cd6383f3
33 changed files with 744 additions and 277 deletions
+8 -5
View File
@@ -30,10 +30,6 @@ const github = {
const $ = cheerio.load(response);
const name = $(selectors.user.name).text().trim();
if (typeof name !== "string" || !name?.length) {
throw new Error("User not found");
}
const location = $(selectors.user.location).text().trim();
const followers = intval($(selectors.user.followers).text().trim());
const following = intval($(selectors.user.following).text().trim());
@@ -45,7 +41,14 @@ const github = {
achievements.push({ name, image });
});
return { name, username, location, followers, following, achievements };
return {
name: name || username,
username,
location,
followers,
following,
achievements,
};
},
async getRepositories(
+1 -1
View File
@@ -6,7 +6,7 @@ import type { JobNames } from "@server/jobs";
const queue = new Queue<any, any, JobNames>(BULLMQ_JOB_NAME, {
connection: BULLMQ_CONNECTION,
defaultJobOptions: {
attempts: 5,
attempts: 3,
backoff: {
type: "exponential",
delay: 3000,
+12
View File
@@ -8,3 +8,15 @@ export const intval = (value: any) => {
const num = parseInt(value);
return Number.isNaN(num) ? 0 : num;
};
export const getLanguageLogo = (language: string) => {
const alias: Record<string, string> = {
gdscript: "godot",
};
let lang = language.toLowerCase().replace(/[^a-zA-Z]/g, "");
lang = alias[lang] || lang;
const uri = `https://github.com/devicons/devicon/raw/master/icons/${lang}/${lang}-original.svg`;
return uri;
};