Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.

Commit c2085db

Browse files
authored
Remove assumptions about total number of records
1 parent ea81579 commit c2085db

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cmd/main.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ func recentPRs(prs []configs.ExternalPRDetails) []github.PullRequest {
496496

497497
// return the top n items
498498
// n is 5 for now
499-
return allPRs[:5]
499+
return allPRs[:min(len(allPRs), 5)]
500500
}
501501

502502
func recentIssues(issues []configs.ExternalIssueDetails) []github.Issue {
@@ -513,7 +513,7 @@ func recentIssues(issues []configs.ExternalIssueDetails) []github.Issue {
513513

514514
// return the top n items
515515
// n is 5 for now
516-
return allIssues[:5]
516+
return allIssues[:min(len(allIssues), 5)]
517517
}
518518

519519
func recentReleases(releases []configs.ExternalReleaseDetails) []github.RepositoryRelease {
@@ -530,5 +530,12 @@ func recentReleases(releases []configs.ExternalReleaseDetails) []github.Reposito
530530

531531
// return the top n items
532532
// n is 5 for now
533-
return allReleases[:5]
533+
return allReleases[:min(len(allReleases), 5)]
534+
}
535+
536+
func min(a, b int) int {
537+
if a < b {
538+
return a
539+
}
540+
return b
534541
}

0 commit comments

Comments
 (0)