Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
fix: location update (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cahllagerfeld authored Jun 16, 2022
1 parent c6bf29a commit 8f37d8b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 19 additions & 14 deletions src/github/github-profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,28 @@ export class GithubProfileService {
HttpStatus.NOT_FOUND,
);
}
if (!githubProfile.location) {
return await this.githubModel.findByIdAndUpdate(
github,
{
$inc: {
__v: 1,
},
},
{ new: true },
);
}
const data = await lastValueFrom(
this.getGithubProfile(github).pipe(
concatMap(async (githubData) => {
Object.keys(githubData).forEach((key) => {
if (githubData[key] === null) {
delete githubData[key];
}
});
if (!githubData.location) return githubData;
return {
location: await this.geocodingService.fetchCoordinates(
githubData.location,
),
name: githubData.name,
};
}),
),
);
return await this.githubModel.findByIdAndUpdate(
github,
{
location: await this.geocodingService.fetchCoordinates(
githubProfile.location.provided,
),
location: data.location,
$inc: {
__v: 1,
},
Expand Down

0 comments on commit 8f37d8b

Please sign in to comment.