@@ -169,16 +169,19 @@ func (g *GithubService) GetFirstContributionYearByUsername(ctx context.Context,
169169}
170170
171171type CurrentContributionStreak struct {
172- Streak int
173- StartedAt time.Time
172+ Streak int
173+ Contributions int
174+ StartedAt time.Time
174175}
175176
176177func (c CurrentContributionStreak ) String () string {
177- msg := fmt .Sprintf ("current contribution streak: %d days" , c .Streak )
178+ msg := fmt .Sprintf ("current contribution streak\n streak : %d days" , c .Streak )
178179 if c .Streak > 0 {
179- msg = fmt .Sprintf ("%s started at: %s" , msg , c .StartedAt .Format ("2006-01-02" ))
180+ msg = fmt .Sprintf ("%s\n started at: %s" , msg , c .StartedAt .Format ("2006-01-02" ))
180181 }
181182
183+ msg = fmt .Sprintf ("%s\n contributions: %d" , msg , c .Contributions )
184+
182185 return msg
183186}
184187
@@ -212,23 +215,30 @@ func (g *GithubService) GetCurrentContributionStreakByUsername(ctx context.Conte
212215 }
213216 currentContributionStreak .StartedAt = d .Date
214217
218+ currentContributionStreak .Contributions += d .ContributionCount
219+
215220 currentContributionStreak .Streak ++
216221 }
217222
218223 return currentContributionStreak , nil
219224}
220225
221226type LongestContributionStreak struct {
222- Streak int
223- StartedAt time.Time
224- EndedAt time.Time
227+ Streak int
228+ Contributions int
229+ StartedAt time.Time
230+ EndedAt time.Time
225231}
226232
227233func (c LongestContributionStreak ) String () string {
234+ startAt := c .StartedAt .Format ("2006-01-02" )
235+ msg := "longest contribution streak"
236+
228237 if c .EndedAt .IsZero () {
229- return fmt .Sprintf ("longest and current contribution streak : %d days started at: %s" , c .Streak , c . StartedAt . Format ( "2006-01-02" ) )
238+ return fmt .Sprintf ("%s \n streak : %d days\n started at: %s" , msg , c .Streak , startAt )
230239 }
231- return fmt .Sprintf ("longest contribution streak: %d days started at: %s ended at: %s" , c .Streak , c .StartedAt .Format ("2006-01-02" ), c .EndedAt .Format ("2006-01-02" ))
240+
241+ return fmt .Sprintf ("%s\n streak: %d days\n started at: %s\n ended at: %s\n contributions: %d" , msg , c .Streak , startAt , c .EndedAt .Format ("2006-01-02" ), c .Contributions )
232242}
233243
234244func (g * GithubService ) GetLongestContributionStreakByUsername (ctx context.Context , username string ) (* LongestContributionStreak , error ) {
@@ -265,14 +275,17 @@ func (g *GithubService) GetLongestContributionStreakByUsername(ctx context.Conte
265275 startedAt := time.Time {}
266276 endedAt := time.Time {}
267277 streak := 0
278+ contributionCount := 0
268279 for _ , d := range days {
269280 if d .ContributionCount == 0 {
270281 if streak > longestContributionStreak .Streak {
271282 longestContributionStreak .Streak = streak
272283 longestContributionStreak .StartedAt = startedAt
273284 longestContributionStreak .EndedAt = endedAt
285+ longestContributionStreak .Contributions = contributionCount
274286 }
275287
288+ contributionCount = 0
276289 streak = 0
277290
278291 continue
@@ -283,7 +296,9 @@ func (g *GithubService) GetLongestContributionStreakByUsername(ctx context.Conte
283296 }
284297 startedAt = d .Date
285298
299+ contributionCount += d .ContributionCount
286300 streak ++
301+
287302 }
288303
289304 now := time .Date (time .Now ().Year (), time .Now ().Month (), time .Now ().Day (), 0 , 0 , 0 , 0 , time .UTC )
0 commit comments