@@ -213,4 +213,48 @@ private StreakResult calculateStreaks(List<LocalDate> commitDates) {
213
213
214
214
return new StreakResult (currentStreak , maxStreak );
215
215
}
216
+
217
+ // 시간별 커밋 분석
218
+ public TotalCommitResponseDto getUpdateCommits (String username , LocalDateTime since , LocalDateTime until ) {
219
+ String query = String .format ("""
220
+ query {
221
+ user(login: "%s") {
222
+ contributionsCollection(from: "%s", to: "%s") {
223
+ commitContributionsByRepository {
224
+ contributions(first: 100) {
225
+ nodes {
226
+ occurredAt # ✅ 시간 정보 포함
227
+ }
228
+ }
229
+ }
230
+ }
231
+ }
232
+ }""" , username , since .format (DateTimeFormatter .ISO_DATE_TIME ), until .format (DateTimeFormatter .ISO_DATE_TIME ));
233
+
234
+ Map <String , String > requestBody = Map .of ("query" , query );
235
+
236
+ TotalCommitGraphQLResponse response = webClient .post ()
237
+ .header ("Authorization" , "bearer " + PAT )
238
+ .bodyValue (requestBody )
239
+ .retrieve ()
240
+ .bodyToMono (TotalCommitGraphQLResponse .class )
241
+ .block ();
242
+
243
+ if (response == null || response .getData () == null || response .getData ().getUser () == null ) {
244
+ throw new RuntimeException ("Failed to fetch GitHub data" );
245
+ }
246
+
247
+ TotalCommitGraphQLResponse .ContributionsCollection contributions =
248
+ response .getData ().getUser ().getContributionsCollection ();
249
+
250
+ List <LocalDate > commitDates = extractCommitDates (contributions .getContributionCalendar ());
251
+ StreakResult streaks = calculateStreaks (commitDates );
252
+
253
+ return new TotalCommitResponseDto (
254
+ contributions .getTotalCommitContributions (),
255
+ contributions .getRestrictedContributionsCount (),
256
+ streaks .currentStreak ,
257
+ streaks .maxStreak
258
+ );
259
+ }
216
260
}
0 commit comments