mirror of
https://github.com/khairul169/github-leaderboard.git
synced 2026-09-17 09:53:21 +07:00
feat: migrate db to postgres
This commit is contained in:
@@ -22,13 +22,15 @@ export const fetchRepoContributors = async (
|
||||
throw new Error("Repository not found!");
|
||||
}
|
||||
|
||||
if (!repo.userAccessToken) {
|
||||
const accessToken =
|
||||
repo.userAccessToken || import.meta.env.GITHUB_DEFAULT_TOKEN;
|
||||
if (!accessToken) {
|
||||
throw new Error("User access token not found!");
|
||||
}
|
||||
|
||||
const contributors = await github.getRepoContributors(data.uri, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${repo.userAccessToken}`,
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -42,7 +44,11 @@ export const fetchRepoContributors = async (
|
||||
throw new Error("Cannot update repository!");
|
||||
}
|
||||
|
||||
await queue.add("calculateUserPoints", { userId: result.userId });
|
||||
await queue.add(
|
||||
"calculateUserPoints",
|
||||
{ userId: result.userId },
|
||||
{ jobId: `calculateUserPoints:${result.userId}` }
|
||||
);
|
||||
};
|
||||
|
||||
export const onFetchRepoContribFailed = async (
|
||||
|
||||
@@ -61,5 +61,9 @@ export const fetchRepoData = async (data: FetchRepoDataJobType) => {
|
||||
}
|
||||
});
|
||||
|
||||
await queue.add("calculateUserPoints", { userId: repository.userId });
|
||||
await queue.add(
|
||||
"calculateUserPoints",
|
||||
{ userId: repository.userId },
|
||||
{ jobId: `calculateUserPoints:${repository.userId}` }
|
||||
);
|
||||
};
|
||||
|
||||
@@ -27,5 +27,9 @@ export const fetchUserProfile = async (data: FetchUserProfileType) => {
|
||||
})
|
||||
.where(eq(users.id, user.id));
|
||||
|
||||
await queue.add("calculateUserPoints", { userId: user.id });
|
||||
await queue.add(
|
||||
"calculateUserPoints",
|
||||
{ userId: user.id },
|
||||
{ jobId: `calculateUserPoints:${user.id}` }
|
||||
);
|
||||
};
|
||||
|
||||
@@ -62,7 +62,7 @@ export const fetchUserRepos = async (data: FetchUserRepos) => {
|
||||
data,
|
||||
opts: {
|
||||
attempts: 5,
|
||||
backoff: { type: "exponential", delay: 30000 },
|
||||
backoff: { type: "exponential", delay: 3000 },
|
||||
jobId: `contributors:${data.uri}`,
|
||||
},
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user