Skip to content

Commit

Permalink
Merge pull request #17 from molohala/Feature/information
Browse files Browse the repository at this point in the history
fix: NPE when account's age is less than 7 days
  • Loading branch information
jombidev authored Apr 20, 2024
2 parents c9e3384 + bc159d9 commit b42dc32
Showing 1 changed file with 3 additions and 2 deletions.
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)
)
}
}

0 comments on commit b42dc32

Please sign in to comment.