Fix promises process

This commit is contained in:
ryo-ma 2025-11-25 15:53:25 +09:00
parent 20908aff97
commit f88e07535b

View file

@ -56,20 +56,16 @@ export class GithubApiService extends GithubRepository {
} }
async requestUserInfo(username: string): Promise<UserInfo | ServiceError> { async requestUserInfo(username: string): Promise<UserInfo | ServiceError> {
// Avoid to call others if one of them is null // Avoid to call others if one of them is null
const repository = await this.requestUserRepository(username);
if (repository instanceof ServiceError) {
Logger.error(repository);
return repository;
}
const promises = Promise.allSettled([ const promises = Promise.allSettled([
this.requestUserRepository(username),
this.requestUserActivity(username), this.requestUserActivity(username),
this.requestUserIssue(username), this.requestUserIssue(username),
this.requestUserPullRequest(username), this.requestUserPullRequest(username),
]); ]);
const [activity, issue, pullRequest] = await promises; const [repository, activity, issue, pullRequest] = await promises;
const status = [ const status = [
repository.status,
activity.status, activity.status,
issue.status, issue.status,
pullRequest.status, pullRequest.status,
@ -84,7 +80,7 @@ export class GithubApiService extends GithubRepository {
(activity as PromiseFulfilledResult<GitHubUserActivity>).value, (activity as PromiseFulfilledResult<GitHubUserActivity>).value,
(issue as PromiseFulfilledResult<GitHubUserIssue>).value, (issue as PromiseFulfilledResult<GitHubUserIssue>).value,
(pullRequest as PromiseFulfilledResult<GitHubUserPullRequest>).value, (pullRequest as PromiseFulfilledResult<GitHubUserPullRequest>).value,
repository, (repository as PromiseFulfilledResult<GitHubUserRepository>).value,
); );
} }