RFR: 1821: The 'timeline` API in GitHub doesn't point out the sorting order

Erik Joelsson erikj at openjdk.org
Wed Feb 15 14:07:13 UTC 2023


On Wed, 15 Feb 2023 10:31:55 GMT, Guoxiong Li <gli at openjdk.org> wrote:

> Hi all,
> 
> This patch adjusts the code to avoid GitHub changing the sorting order of the `timeline` API in the future.
> I worry that the time complexity may change from O(N) to O(N*N), but not sure.
> 
> Thanks for the review.
> 
> Best Regards,
> -- Guoxiong

forge/src/main/java/org/openjdk/skara/forge/github/GitHubPullRequest.java line 776:

> 774:                           var secondTime = ZonedDateTime.parse(second.get("created_at").asString());
> 775:                           return firstTime.compareTo(secondTime);
> 776:                       })

Suggestion:

                      .max(Comparator.comparing(o -> ZonedDateTime.parse(o.get("created_at").asString())))

forge/src/main/java/org/openjdk/skara/forge/github/GitHubPullRequest.java line 797:

> 795:                 .filter(obj -> ZonedDateTime.parse(obj.get("created_at").asString()).isAfter(lastMarkedAsReadyTime(timelineJSON)))
> 796:                 .map(obj -> ZonedDateTime.parse(obj.get("created_at").asString()))
> 797:                 .max(ZonedDateTime::compareTo);

Suggestion:

                .max(Comparator.naturalOrder());

-------------

PR: https://git.openjdk.org/skara/pull/1473


More information about the skara-dev mailing list