Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: NPE when account's age is less than 7 days #17

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.molohala.infinityinfra.api.github

import com.fasterxml.jackson.databind.ObjectMapper
import com.molohala.infinitycore.info.GithubInfoClient
import com.molohala.infinitycore.info.application.dto.GithubContribute
import com.molohala.infinitycore.info.application.dto.GithubUserInfo
import org.slf4j.LoggerFactory
import org.springframework.graphql.client.HttpGraphQlClient
Expand Down Expand Up @@ -53,7 +54,7 @@ class GithubClient(

val today = LocalDate.now()
val weekContribute = today.minusDays(7).datesUntil(today).map { date ->
calendar.weeks.find { it.date == date }!! // NPE won't happen
calendar.weeks.find { it.date == date } ?: GithubContribute(date, 0)
}

return GithubUserInfo(
Expand All @@ -62,7 +63,7 @@ class GithubClient(
bio = entity.bio,
totalCommits = calendar.totalContributions,
weekCommits = weekContribute.toList(),
todayCommits = calendar.weeks.find { it.date == today }!!
todayCommits = calendar.weeks.find { it.date == today } ?: GithubContribute(today, 0)
)
}
}
Loading