mirror of
https://github.com/khairul169/github-leaderboard.git
synced 2026-09-17 09:53:21 +07:00
feat: add leaderboard category
This commit is contained in:
@@ -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
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user