From b1017315df14f5345f2c743aee0e41dc066234ab Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Thu, 4 Jan 2024 11:24:30 +0800 Subject: [PATCH 01/11] ADM-675: [backend]feat:config cache for getJiraCards method in JiraFeignClient --- backend/src/main/java/heartbeat/client/JiraFeignClient.java | 1 + backend/src/main/java/heartbeat/config/CacheConfig.java | 1 + 2 files changed, 2 insertions(+) diff --git a/backend/src/main/java/heartbeat/client/JiraFeignClient.java b/backend/src/main/java/heartbeat/client/JiraFeignClient.java index ef560a41c3..7699432059 100644 --- a/backend/src/main/java/heartbeat/client/JiraFeignClient.java +++ b/backend/src/main/java/heartbeat/client/JiraFeignClient.java @@ -28,6 +28,7 @@ JiraBoardConfigDTO getJiraBoardConfiguration(URI baseUrl, @PathVariable String b StatusSelfDTO getColumnStatusCategory(URI baseUrl, @PathVariable String statusNum, @RequestHeader String authorization); + @Cacheable(cacheNames = "jiraCards", key = "#boardId+'-'+#queryCount+'-'+#startAt+'-'+#jql") @GetMapping(path = "/rest/agile/1.0/board/{boardId}/issue?maxResults={queryCount}&startAt={startAt}&jql={jql}") String getJiraCards(URI baseUrl, @PathVariable String boardId, @PathVariable int queryCount, @PathVariable int startAt, @PathVariable String jql, @RequestHeader String authorization); diff --git a/backend/src/main/java/heartbeat/config/CacheConfig.java b/backend/src/main/java/heartbeat/config/CacheConfig.java index 783c9e46a2..61d45ab0fb 100644 --- a/backend/src/main/java/heartbeat/config/CacheConfig.java +++ b/backend/src/main/java/heartbeat/config/CacheConfig.java @@ -35,6 +35,7 @@ public CacheManager ehCacheManager() { cacheManager.createCache("targetField", getCacheConfiguration(FieldResponseDTO.class)); cacheManager.createCache("boardVerification", getCacheConfiguration(JiraBoardVerifyDTO.class)); cacheManager.createCache("boardProject", getCacheConfiguration(JiraBoardProject.class)); + cacheManager.createCache("jiraCards", getCacheConfiguration(String.class)); return cacheManager; } From 97cec4fe2ade4ea6756c63595590ef16dd90819e Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Thu, 4 Jan 2024 11:33:53 +0800 Subject: [PATCH 02/11] ADM-675: [backend]feat:config cache for getHolidays method in HolidayFeignClient --- backend/src/main/java/heartbeat/client/HolidayFeignClient.java | 2 ++ backend/src/main/java/heartbeat/config/CacheConfig.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/backend/src/main/java/heartbeat/client/HolidayFeignClient.java b/backend/src/main/java/heartbeat/client/HolidayFeignClient.java index 51ba6c75a9..e8a73b3db1 100644 --- a/backend/src/main/java/heartbeat/client/HolidayFeignClient.java +++ b/backend/src/main/java/heartbeat/client/HolidayFeignClient.java @@ -2,6 +2,7 @@ import heartbeat.client.dto.board.jira.HolidaysResponseDTO; import heartbeat.config.HolidayFeignClientConfiguration; +import org.springframework.cache.annotation.Cacheable; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -10,6 +11,7 @@ configuration = HolidayFeignClientConfiguration.class) public interface HolidayFeignClient { + @Cacheable(cacheNames = "holidayResult", key = "#year") @GetMapping(path = "/{year}.json") HolidaysResponseDTO getHolidays(@PathVariable String year); diff --git a/backend/src/main/java/heartbeat/config/CacheConfig.java b/backend/src/main/java/heartbeat/config/CacheConfig.java index 61d45ab0fb..295eaa5807 100644 --- a/backend/src/main/java/heartbeat/config/CacheConfig.java +++ b/backend/src/main/java/heartbeat/config/CacheConfig.java @@ -10,6 +10,8 @@ import javax.cache.CacheManager; import javax.cache.Caching; import javax.cache.spi.CachingProvider; + +import heartbeat.client.dto.board.jira.HolidaysResponseDTO; import lombok.val; import org.ehcache.config.builders.CacheConfigurationBuilder; import org.ehcache.config.builders.ExpiryPolicyBuilder; @@ -36,6 +38,7 @@ public CacheManager ehCacheManager() { cacheManager.createCache("boardVerification", getCacheConfiguration(JiraBoardVerifyDTO.class)); cacheManager.createCache("boardProject", getCacheConfiguration(JiraBoardProject.class)); cacheManager.createCache("jiraCards", getCacheConfiguration(String.class)); + cacheManager.createCache("holidayResult", getCacheConfiguration(HolidaysResponseDTO.class)); return cacheManager; } From 241a6c3948a128a2c9cb138949e10004f57c5ed0 Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Mon, 8 Jan 2024 11:43:07 +0800 Subject: [PATCH 03/11] ADM-675: [backend]fix:fix the error that holidayDTO can not be serialized --- .../main/java/heartbeat/client/dto/board/jira/HolidayDTO.java | 4 +++- .../heartbeat/client/dto/board/jira/HolidaysResponseDTO.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/heartbeat/client/dto/board/jira/HolidayDTO.java b/backend/src/main/java/heartbeat/client/dto/board/jira/HolidayDTO.java index 345fec0391..7610d6e01e 100644 --- a/backend/src/main/java/heartbeat/client/dto/board/jira/HolidayDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/board/jira/HolidayDTO.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class HolidayDTO { +public class HolidayDTO implements Serializable { private String name; diff --git a/backend/src/main/java/heartbeat/client/dto/board/jira/HolidaysResponseDTO.java b/backend/src/main/java/heartbeat/client/dto/board/jira/HolidaysResponseDTO.java index 07e5e11e0e..2a0896791f 100644 --- a/backend/src/main/java/heartbeat/client/dto/board/jira/HolidaysResponseDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/board/jira/HolidaysResponseDTO.java @@ -6,6 +6,7 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.List; @Data @@ -13,7 +14,7 @@ @NoArgsConstructor @AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class HolidaysResponseDTO { +public class HolidaysResponseDTO implements Serializable { private List days; From 9f95124a3ad4284d96495e2123d3ebb8fffd3a7c Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Mon, 8 Jan 2024 16:30:11 +0800 Subject: [PATCH 04/11] ADM-675: [backend]feat:config cache for all method in BuildKiteFeignClient --- .../main/java/heartbeat/client/BuildKiteFeignClient.java | 7 +++++++ .../client/dto/pipeline/buildkite/BuildKiteBuildInfo.java | 3 ++- .../client/dto/pipeline/buildkite/BuildKiteJob.java | 4 +++- .../dto/pipeline/buildkite/BuildKiteOrganizationsInfo.java | 4 +++- .../dto/pipeline/buildkite/BuildKitePipelineDTO.java | 3 ++- .../client/dto/pipeline/buildkite/BuildKiteTokenInfo.java | 3 ++- .../client/dto/pipeline/buildkite/CreatedByDTO.java | 3 ++- .../heartbeat/client/dto/pipeline/buildkite/EnvDTO.java | 4 +++- .../client/dto/pipeline/buildkite/ProviderDTO.java | 4 +++- .../client/dto/pipeline/buildkite/ProviderSettingsDTO.java | 4 +++- .../heartbeat/client/dto/pipeline/buildkite/StepsDTO.java | 4 +++- backend/src/main/java/heartbeat/config/CacheConfig.java | 6 ++++++ 12 files changed, 39 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/heartbeat/client/BuildKiteFeignClient.java b/backend/src/main/java/heartbeat/client/BuildKiteFeignClient.java index f2b26be7b9..74e30c2b61 100644 --- a/backend/src/main/java/heartbeat/client/BuildKiteFeignClient.java +++ b/backend/src/main/java/heartbeat/client/BuildKiteFeignClient.java @@ -8,6 +8,7 @@ import java.util.List; +import org.springframework.cache.annotation.Cacheable; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -21,14 +22,17 @@ @FeignClient(name = "buildKiteFeignClient", url = "${buildKite.url}", configuration = BuildKiteFeignClientDecoder.class) public interface BuildKiteFeignClient { + @Cacheable(cacheNames = "tokenInfo", key = "#token") @GetMapping(path = "v2/access-token") @ResponseStatus(HttpStatus.OK) BuildKiteTokenInfo getTokenInfo(@RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "buildKiteOrganizationInfo", key = "#token") @GetMapping(path = "v2/organizations") @ResponseStatus(HttpStatus.OK) List getBuildKiteOrganizationsInfo(@RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "pipelineInfo", key = "#organizationId+'-'+#page+'-'+#perPage+'-'+#startTime+'-'+#endTime") @GetMapping(path = "v2/organizations/{organizationId}/pipelines?page={page}&per_page={perPage}") @ResponseStatus(HttpStatus.OK) List getPipelineInfo(@RequestHeader("Authorization") String token, @@ -43,6 +47,9 @@ ResponseEntity> getPipelineSteps(@RequestHeader("Author @RequestParam("per_page") String perPage, @RequestParam("created_from") String createdFrom, @RequestParam("created_to") String createdTo, @RequestParam("branch[]") List branch); + @Cacheable(cacheNames = "pipelineStepsInfo", + key = "#organizationId+'-'+#pipelineId+'-'+#page+'-'+#perPage+'-'" + + "+#createdFrom+'-'+#createdTo+'-'+(#branch!=null ? branch.toString() : '')") @GetMapping(path = "v2/organizations/{organizationId}/pipelines/{pipelineId}/builds", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @ResponseStatus(HttpStatus.OK) diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java index 078fa80926..4afadd19f6 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java @@ -8,6 +8,7 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.time.Instant; import java.util.Comparator; import java.util.List; @@ -18,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class BuildKiteBuildInfo { +public class BuildKiteBuildInfo implements Serializable { private List jobs; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteJob.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteJob.java index d9fb5b84ce..204c60d905 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteJob.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteJob.java @@ -7,12 +7,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @JsonIgnoreProperties(ignoreUnknown = true) @Builder @NoArgsConstructor @AllArgsConstructor -public class BuildKiteJob { +public class BuildKiteJob implements Serializable { private String name; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteOrganizationsInfo.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteOrganizationsInfo.java index 80e5a66a9b..c643b710f7 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteOrganizationsInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteOrganizationsInfo.java @@ -6,12 +6,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class BuildKiteOrganizationsInfo { +public class BuildKiteOrganizationsInfo implements Serializable { private String name; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKitePipelineDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKitePipelineDTO.java index 9acdab32f6..4c6e0ac6bf 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKitePipelineDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKitePipelineDTO.java @@ -7,6 +7,7 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.Date; import java.util.List; @@ -15,7 +16,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class BuildKitePipelineDTO { +public class BuildKitePipelineDTO implements Serializable { private String id; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteTokenInfo.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteTokenInfo.java index b217c3fa13..ae65912e54 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteTokenInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteTokenInfo.java @@ -6,6 +6,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.List; @AllArgsConstructor @@ -13,7 +14,7 @@ @Getter @Builder @JsonIgnoreProperties(ignoreUnknown = true) -public class BuildKiteTokenInfo { +public class BuildKiteTokenInfo implements Serializable { private List scopes; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/CreatedByDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/CreatedByDTO.java index 39cd559501..5c32e9e343 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/CreatedByDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/CreatedByDTO.java @@ -6,6 +6,7 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.Date; @Data @@ -13,7 +14,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class CreatedByDTO { +public class CreatedByDTO implements Serializable { private String id; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/EnvDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/EnvDTO.java index 489e21e75f..011eaa1112 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/EnvDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/EnvDTO.java @@ -5,10 +5,12 @@ import lombok.Builder; import lombok.Data; +import java.io.Serializable; + @Data @Builder @AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class EnvDTO { +public class EnvDTO implements Serializable { } diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderDTO.java index 38522b3cb1..cdaa576862 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderDTO.java @@ -7,12 +7,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class ProviderDTO { +public class ProviderDTO implements Serializable { private String id; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderSettingsDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderSettingsDTO.java index b6aaa2eaf5..ff8c893866 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderSettingsDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderSettingsDTO.java @@ -7,12 +7,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class ProviderSettingsDTO { +public class ProviderSettingsDTO implements Serializable { @JsonProperty("trigger_mode") private String triggerMode; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/StepsDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/StepsDTO.java index 00c9323201..df1c5d9c2a 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/StepsDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/StepsDTO.java @@ -7,12 +7,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class StepsDTO { +public class StepsDTO implements Serializable { private String type; diff --git a/backend/src/main/java/heartbeat/config/CacheConfig.java b/backend/src/main/java/heartbeat/config/CacheConfig.java index 295eaa5807..0b5c196b44 100644 --- a/backend/src/main/java/heartbeat/config/CacheConfig.java +++ b/backend/src/main/java/heartbeat/config/CacheConfig.java @@ -7,11 +7,13 @@ import heartbeat.client.dto.board.jira.JiraBoardVerifyDTO; import heartbeat.client.dto.board.jira.StatusSelfDTO; import java.time.Duration; +import java.util.List; import javax.cache.CacheManager; import javax.cache.Caching; import javax.cache.spi.CachingProvider; import heartbeat.client.dto.board.jira.HolidaysResponseDTO; +import heartbeat.client.dto.pipeline.buildkite.BuildKiteTokenInfo; import lombok.val; import org.ehcache.config.builders.CacheConfigurationBuilder; import org.ehcache.config.builders.ExpiryPolicyBuilder; @@ -39,6 +41,10 @@ public CacheManager ehCacheManager() { cacheManager.createCache("boardProject", getCacheConfiguration(JiraBoardProject.class)); cacheManager.createCache("jiraCards", getCacheConfiguration(String.class)); cacheManager.createCache("holidayResult", getCacheConfiguration(HolidaysResponseDTO.class)); + cacheManager.createCache("tokenInfo", getCacheConfiguration(BuildKiteTokenInfo.class)); + cacheManager.createCache("buildKiteOrganizationInfo", getCacheConfiguration(List.class)); + cacheManager.createCache("pipelineInfo", getCacheConfiguration(List.class)); + cacheManager.createCache("pipelineStepsInfo", getCacheConfiguration(List.class)); return cacheManager; } From f439587648e65057cdfc844d8b0a83ecc86ef212 Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Mon, 8 Jan 2024 16:33:50 +0800 Subject: [PATCH 05/11] ADM-675: [backend]feat:config cache for all method in GitHubFeignClient --- .../src/main/java/heartbeat/client/GitHubFeignClient.java | 7 +++++++ .../java/heartbeat/client/dto/codebase/github/Author.java | 4 +++- .../heartbeat/client/dto/codebase/github/AuthorOuter.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Base.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Comment.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Commit.java | 4 +++- .../heartbeat/client/dto/codebase/github/CommitInfo.java | 3 ++- .../java/heartbeat/client/dto/codebase/github/Commits.java | 4 +++- .../heartbeat/client/dto/codebase/github/Committer.java | 4 +++- .../client/dto/codebase/github/CommitterOuter.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/File.java | 4 +++- .../dto/codebase/github/GitHubOrganizationsInfo.java | 4 +++- .../heartbeat/client/dto/codebase/github/GitHubRepo.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Head.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Html.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Issue.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/License.java | 4 +++- .../client/dto/codebase/github/LinkCollection.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Owner.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Parent.java | 4 +++- .../client/dto/codebase/github/PullRequestInfo.java | 3 ++- .../java/heartbeat/client/dto/codebase/github/Repo.java | 5 ++--- .../client/dto/codebase/github/ReviewComment.java | 4 +++- .../client/dto/codebase/github/ReviewComments.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Self.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Stats.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Status.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Tree.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/User.java | 4 +++- .../heartbeat/client/dto/codebase/github/Verification.java | 4 +++- backend/src/main/java/heartbeat/config/CacheConfig.java | 7 +++++++ 31 files changed, 98 insertions(+), 31 deletions(-) diff --git a/backend/src/main/java/heartbeat/client/GitHubFeignClient.java b/backend/src/main/java/heartbeat/client/GitHubFeignClient.java index c07d2163d6..b6f0b880bc 100644 --- a/backend/src/main/java/heartbeat/client/GitHubFeignClient.java +++ b/backend/src/main/java/heartbeat/client/GitHubFeignClient.java @@ -5,6 +5,7 @@ import heartbeat.client.dto.codebase.github.GitHubRepo; import heartbeat.client.dto.codebase.github.PullRequestInfo; import heartbeat.decoder.GitHubFeignClientDecoder; +import org.springframework.cache.annotation.Cacheable; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; @@ -17,29 +18,35 @@ @FeignClient(name = "githubFeignClient", url = "${github.url}", configuration = GitHubFeignClientDecoder.class) public interface GitHubFeignClient { + @Cacheable(cacheNames = "githubOrganizationInfo", key = "#token") @GetMapping(path = "/user/orgs") @ResponseStatus(HttpStatus.OK) List getGithubOrganizationsInfo(@RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "githubAllRepos", key = "#token") @GetMapping(path = "/user/repos") @ResponseStatus(HttpStatus.OK) List getAllRepos(@RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "githubRepos", key = "#organizationName") @GetMapping(path = "/orgs/{organizationName}/repos") @ResponseStatus(HttpStatus.OK) List getReposByOrganizationName(@PathVariable String organizationName, @RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "commitInfo", key = "#repository+'-'+#commitId") @GetMapping(path = "/repos/{repository}/commits/{commitId}") @ResponseStatus(HttpStatus.OK) CommitInfo getCommitInfo(@PathVariable String repository, @PathVariable String commitId, @RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "pullRequestCommitInfo", key = "#repository+'-'+#mergedPullNumber") @GetMapping(path = "/repos/{repository}/pulls/{mergedPullNumber}/commits") @ResponseStatus(HttpStatus.OK) List getPullRequestCommitInfo(@PathVariable String repository, @PathVariable String mergedPullNumber, @RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "pullRequestListInfo", key = "#repository+'-'+#deployId") @GetMapping(path = "/repos/{repository}/commits/{deployId}/pulls") @ResponseStatus(HttpStatus.OK) List getPullRequestListInfo(@PathVariable String repository, @PathVariable String deployId, diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Author.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Author.java index 415198e2ac..da481a3f19 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Author.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Author.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Author { +public class Author implements Serializable { private String name; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/AuthorOuter.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/AuthorOuter.java index 8be0cc0528..566a81519c 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/AuthorOuter.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/AuthorOuter.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class AuthorOuter { +public class AuthorOuter implements Serializable { private String login; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Base.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Base.java index ac96c750e0..e2bc62608b 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Base.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Base.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Base { +public class Base implements Serializable { private String label; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Comment.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Comment.java index ff97ba624b..84d4dfbfcb 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Comment.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Comment.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Comment { +public class Comment implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Commit.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Commit.java index 6309b1b558..2af13c7134 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Commit.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Commit.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Commit { +public class Commit implements Serializable { private Author author; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitInfo.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitInfo.java index 1f6a55e9a1..6fdf70289a 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitInfo.java @@ -6,13 +6,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.List; @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class CommitInfo { +public class CommitInfo implements Serializable { private String sha; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Commits.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Commits.java index 1db391606a..6a6087d8fc 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Commits.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Commits.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Commits { +public class Commits implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Committer.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Committer.java index 50fd43c57c..136c19dad6 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Committer.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Committer.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Committer { +public class Committer implements Serializable { private String name; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitterOuter.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitterOuter.java index becaf04070..23eb7d5cef 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitterOuter.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitterOuter.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class CommitterOuter { +public class CommitterOuter implements Serializable { private String login; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/File.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/File.java index 8f7b7c3330..5279069781 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/File.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/File.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class File { +public class File implements Serializable { private String sha; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubOrganizationsInfo.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubOrganizationsInfo.java index d7833728ea..a16ecdf8ce 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubOrganizationsInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubOrganizationsInfo.java @@ -6,12 +6,14 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.io.Serializable; + @AllArgsConstructor @NoArgsConstructor @Getter @Builder @JsonIgnoreProperties(ignoreUnknown = true) -public class GitHubOrganizationsInfo { +public class GitHubOrganizationsInfo implements Serializable { private String login; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubRepo.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubRepo.java index 97d4f42186..e806cf8b88 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubRepo.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubRepo.java @@ -7,12 +7,14 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.io.Serializable; + @AllArgsConstructor @NoArgsConstructor @Getter @Builder @JsonIgnoreProperties(ignoreUnknown = true) -public class GitHubRepo { +public class GitHubRepo implements Serializable { @JsonProperty("html_url") private String htmlUrl; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Head.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Head.java index c8666a1b87..dab44a8da7 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Head.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Head.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Head { +public class Head implements Serializable { private String label; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Html.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Html.java index 4323338dbd..c9f7b0d42c 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Html.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Html.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Html { +public class Html implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Issue.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Issue.java index fe24e2e905..b935061bb3 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Issue.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Issue.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Issue { +public class Issue implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/License.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/License.java index 74350cf99d..46ce69b932 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/License.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/License.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class License { +public class License implements Serializable { private String key; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/LinkCollection.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/LinkCollection.java index e6d588c70c..5caf031822 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/LinkCollection.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/LinkCollection.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class LinkCollection { +public class LinkCollection implements Serializable { private Self self; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Owner.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Owner.java index a33378eec5..24fd8a1a92 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Owner.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Owner.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Owner { +public class Owner implements Serializable { private String login; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Parent.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Parent.java index 67523769c8..291a39b40f 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Parent.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Parent.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Parent { +public class Parent implements Serializable { private String sha; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/PullRequestInfo.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/PullRequestInfo.java index b5bf8e20de..f0672a2b36 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/PullRequestInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/PullRequestInfo.java @@ -7,6 +7,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.List; @Data @@ -14,7 +15,7 @@ @NoArgsConstructor @AllArgsConstructor @Getter -public class PullRequestInfo { +public class PullRequestInfo implements Serializable { private String url; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Repo.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Repo.java index 94991be6a9..ee55d42092 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Repo.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Repo.java @@ -1,20 +1,19 @@ package heartbeat.client.dto.codebase.github; import com.fasterxml.jackson.annotation.JsonProperty; -import heartbeat.client.dto.codebase.github.License; -import heartbeat.client.dto.codebase.github.Owner; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.List; @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Repo { +public class Repo implements Serializable { private Integer id; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComment.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComment.java index 6828b6b3db..52d50eff3e 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComment.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComment.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class ReviewComment { +public class ReviewComment implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComments.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComments.java index f71d3eef76..b040cf3f29 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComments.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComments.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class ReviewComments { +public class ReviewComments implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Self.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Self.java index b6615ae9ad..20aa3b6afb 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Self.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Self.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Self { +public class Self implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Stats.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Stats.java index 8a35608185..ce1dd29918 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Stats.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Stats.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Stats { +public class Stats implements Serializable { private Integer total; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Status.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Status.java index 4f8e827c97..59d115d7f9 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Status.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Status.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Status { +public class Status implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Tree.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Tree.java index db4d8b9936..2bb563eed6 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Tree.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Tree.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Tree { +public class Tree implements Serializable { private String sha; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/User.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/User.java index 181c9e4c3e..4d82094d20 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/User.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/User.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class User { +public class User implements Serializable { private String login; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Verification.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Verification.java index abfcb34f66..5991419b87 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Verification.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Verification.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Verification { +public class Verification implements Serializable { private Boolean verified; diff --git a/backend/src/main/java/heartbeat/config/CacheConfig.java b/backend/src/main/java/heartbeat/config/CacheConfig.java index 0b5c196b44..7c777f87eb 100644 --- a/backend/src/main/java/heartbeat/config/CacheConfig.java +++ b/backend/src/main/java/heartbeat/config/CacheConfig.java @@ -13,6 +13,7 @@ import javax.cache.spi.CachingProvider; import heartbeat.client.dto.board.jira.HolidaysResponseDTO; +import heartbeat.client.dto.codebase.github.CommitInfo; import heartbeat.client.dto.pipeline.buildkite.BuildKiteTokenInfo; import lombok.val; import org.ehcache.config.builders.CacheConfigurationBuilder; @@ -45,6 +46,12 @@ public CacheManager ehCacheManager() { cacheManager.createCache("buildKiteOrganizationInfo", getCacheConfiguration(List.class)); cacheManager.createCache("pipelineInfo", getCacheConfiguration(List.class)); cacheManager.createCache("pipelineStepsInfo", getCacheConfiguration(List.class)); + cacheManager.createCache("githubOrganizationInfo", getCacheConfiguration(List.class)); + cacheManager.createCache("githubAllRepos", getCacheConfiguration(List.class)); + cacheManager.createCache("githubRepos", getCacheConfiguration(List.class)); + cacheManager.createCache("commitInfo", getCacheConfiguration(CommitInfo.class)); + cacheManager.createCache("pullRequestCommitInfo", getCacheConfiguration(List.class)); + cacheManager.createCache("pullRequestListInfo", getCacheConfiguration(List.class)); return cacheManager; } From d641164badc7a55b0e16c162d4ec6cf656daf398 Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Thu, 4 Jan 2024 11:24:30 +0800 Subject: [PATCH 06/11] ADM-675: [backend]feat:config cache for getJiraCards method in JiraFeignClient --- backend/src/main/java/heartbeat/client/JiraFeignClient.java | 1 + backend/src/main/java/heartbeat/config/CacheConfig.java | 1 + 2 files changed, 2 insertions(+) diff --git a/backend/src/main/java/heartbeat/client/JiraFeignClient.java b/backend/src/main/java/heartbeat/client/JiraFeignClient.java index 1e62c0c44f..0cdf8aeb63 100644 --- a/backend/src/main/java/heartbeat/client/JiraFeignClient.java +++ b/backend/src/main/java/heartbeat/client/JiraFeignClient.java @@ -28,6 +28,7 @@ JiraBoardConfigDTO getJiraBoardConfiguration(URI baseUrl, @PathVariable String b StatusSelfDTO getColumnStatusCategory(URI baseUrl, @PathVariable String statusNum, @RequestHeader String authorization); + @Cacheable(cacheNames = "jiraCards", key = "#boardId+'-'+#queryCount+'-'+#startAt+'-'+#jql") @GetMapping(path = "/rest/agile/1.0/board/{boardId}/issue?maxResults={queryCount}&startAt={startAt}&jql={jql}") String getJiraCards(URI baseUrl, @PathVariable String boardId, @PathVariable int queryCount, @PathVariable int startAt, @PathVariable String jql, @RequestHeader String authorization); diff --git a/backend/src/main/java/heartbeat/config/CacheConfig.java b/backend/src/main/java/heartbeat/config/CacheConfig.java index 783c9e46a2..61d45ab0fb 100644 --- a/backend/src/main/java/heartbeat/config/CacheConfig.java +++ b/backend/src/main/java/heartbeat/config/CacheConfig.java @@ -35,6 +35,7 @@ public CacheManager ehCacheManager() { cacheManager.createCache("targetField", getCacheConfiguration(FieldResponseDTO.class)); cacheManager.createCache("boardVerification", getCacheConfiguration(JiraBoardVerifyDTO.class)); cacheManager.createCache("boardProject", getCacheConfiguration(JiraBoardProject.class)); + cacheManager.createCache("jiraCards", getCacheConfiguration(String.class)); return cacheManager; } From f691d7ab791e6900cfc8a1242556e5face54f742 Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Thu, 4 Jan 2024 11:33:53 +0800 Subject: [PATCH 07/11] ADM-675: [backend]feat:config cache for getHolidays method in HolidayFeignClient --- backend/src/main/java/heartbeat/client/HolidayFeignClient.java | 2 ++ backend/src/main/java/heartbeat/config/CacheConfig.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/backend/src/main/java/heartbeat/client/HolidayFeignClient.java b/backend/src/main/java/heartbeat/client/HolidayFeignClient.java index 51ba6c75a9..e8a73b3db1 100644 --- a/backend/src/main/java/heartbeat/client/HolidayFeignClient.java +++ b/backend/src/main/java/heartbeat/client/HolidayFeignClient.java @@ -2,6 +2,7 @@ import heartbeat.client.dto.board.jira.HolidaysResponseDTO; import heartbeat.config.HolidayFeignClientConfiguration; +import org.springframework.cache.annotation.Cacheable; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -10,6 +11,7 @@ configuration = HolidayFeignClientConfiguration.class) public interface HolidayFeignClient { + @Cacheable(cacheNames = "holidayResult", key = "#year") @GetMapping(path = "/{year}.json") HolidaysResponseDTO getHolidays(@PathVariable String year); diff --git a/backend/src/main/java/heartbeat/config/CacheConfig.java b/backend/src/main/java/heartbeat/config/CacheConfig.java index 61d45ab0fb..295eaa5807 100644 --- a/backend/src/main/java/heartbeat/config/CacheConfig.java +++ b/backend/src/main/java/heartbeat/config/CacheConfig.java @@ -10,6 +10,8 @@ import javax.cache.CacheManager; import javax.cache.Caching; import javax.cache.spi.CachingProvider; + +import heartbeat.client.dto.board.jira.HolidaysResponseDTO; import lombok.val; import org.ehcache.config.builders.CacheConfigurationBuilder; import org.ehcache.config.builders.ExpiryPolicyBuilder; @@ -36,6 +38,7 @@ public CacheManager ehCacheManager() { cacheManager.createCache("boardVerification", getCacheConfiguration(JiraBoardVerifyDTO.class)); cacheManager.createCache("boardProject", getCacheConfiguration(JiraBoardProject.class)); cacheManager.createCache("jiraCards", getCacheConfiguration(String.class)); + cacheManager.createCache("holidayResult", getCacheConfiguration(HolidaysResponseDTO.class)); return cacheManager; } From 387de52aff51486b70daaf927c5e8b384470ba9c Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Mon, 8 Jan 2024 11:43:07 +0800 Subject: [PATCH 08/11] ADM-675: [backend]fix:fix the error that holidayDTO can not be serialized --- .../main/java/heartbeat/client/dto/board/jira/HolidayDTO.java | 4 +++- .../heartbeat/client/dto/board/jira/HolidaysResponseDTO.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/heartbeat/client/dto/board/jira/HolidayDTO.java b/backend/src/main/java/heartbeat/client/dto/board/jira/HolidayDTO.java index 345fec0391..7610d6e01e 100644 --- a/backend/src/main/java/heartbeat/client/dto/board/jira/HolidayDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/board/jira/HolidayDTO.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class HolidayDTO { +public class HolidayDTO implements Serializable { private String name; diff --git a/backend/src/main/java/heartbeat/client/dto/board/jira/HolidaysResponseDTO.java b/backend/src/main/java/heartbeat/client/dto/board/jira/HolidaysResponseDTO.java index 07e5e11e0e..2a0896791f 100644 --- a/backend/src/main/java/heartbeat/client/dto/board/jira/HolidaysResponseDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/board/jira/HolidaysResponseDTO.java @@ -6,6 +6,7 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.List; @Data @@ -13,7 +14,7 @@ @NoArgsConstructor @AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class HolidaysResponseDTO { +public class HolidaysResponseDTO implements Serializable { private List days; From 6bbe636e81f3a6bd24c5c3506aac0697935a90d1 Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Mon, 8 Jan 2024 16:30:11 +0800 Subject: [PATCH 09/11] ADM-675: [backend]feat:config cache for all method in BuildKiteFeignClient --- .../main/java/heartbeat/client/BuildKiteFeignClient.java | 7 +++++++ .../client/dto/pipeline/buildkite/BuildKiteBuildInfo.java | 3 ++- .../client/dto/pipeline/buildkite/BuildKiteJob.java | 4 +++- .../dto/pipeline/buildkite/BuildKiteOrganizationsInfo.java | 4 +++- .../dto/pipeline/buildkite/BuildKitePipelineDTO.java | 3 ++- .../client/dto/pipeline/buildkite/BuildKiteTokenInfo.java | 3 ++- .../client/dto/pipeline/buildkite/CreatedByDTO.java | 3 ++- .../heartbeat/client/dto/pipeline/buildkite/EnvDTO.java | 4 +++- .../client/dto/pipeline/buildkite/ProviderDTO.java | 4 +++- .../client/dto/pipeline/buildkite/ProviderSettingsDTO.java | 4 +++- .../heartbeat/client/dto/pipeline/buildkite/StepsDTO.java | 4 +++- backend/src/main/java/heartbeat/config/CacheConfig.java | 6 ++++++ 12 files changed, 39 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/heartbeat/client/BuildKiteFeignClient.java b/backend/src/main/java/heartbeat/client/BuildKiteFeignClient.java index f2b26be7b9..74e30c2b61 100644 --- a/backend/src/main/java/heartbeat/client/BuildKiteFeignClient.java +++ b/backend/src/main/java/heartbeat/client/BuildKiteFeignClient.java @@ -8,6 +8,7 @@ import java.util.List; +import org.springframework.cache.annotation.Cacheable; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -21,14 +22,17 @@ @FeignClient(name = "buildKiteFeignClient", url = "${buildKite.url}", configuration = BuildKiteFeignClientDecoder.class) public interface BuildKiteFeignClient { + @Cacheable(cacheNames = "tokenInfo", key = "#token") @GetMapping(path = "v2/access-token") @ResponseStatus(HttpStatus.OK) BuildKiteTokenInfo getTokenInfo(@RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "buildKiteOrganizationInfo", key = "#token") @GetMapping(path = "v2/organizations") @ResponseStatus(HttpStatus.OK) List getBuildKiteOrganizationsInfo(@RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "pipelineInfo", key = "#organizationId+'-'+#page+'-'+#perPage+'-'+#startTime+'-'+#endTime") @GetMapping(path = "v2/organizations/{organizationId}/pipelines?page={page}&per_page={perPage}") @ResponseStatus(HttpStatus.OK) List getPipelineInfo(@RequestHeader("Authorization") String token, @@ -43,6 +47,9 @@ ResponseEntity> getPipelineSteps(@RequestHeader("Author @RequestParam("per_page") String perPage, @RequestParam("created_from") String createdFrom, @RequestParam("created_to") String createdTo, @RequestParam("branch[]") List branch); + @Cacheable(cacheNames = "pipelineStepsInfo", + key = "#organizationId+'-'+#pipelineId+'-'+#page+'-'+#perPage+'-'" + + "+#createdFrom+'-'+#createdTo+'-'+(#branch!=null ? branch.toString() : '')") @GetMapping(path = "v2/organizations/{organizationId}/pipelines/{pipelineId}/builds", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @ResponseStatus(HttpStatus.OK) diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java index 078fa80926..4afadd19f6 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java @@ -8,6 +8,7 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.time.Instant; import java.util.Comparator; import java.util.List; @@ -18,7 +19,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class BuildKiteBuildInfo { +public class BuildKiteBuildInfo implements Serializable { private List jobs; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteJob.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteJob.java index d9fb5b84ce..204c60d905 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteJob.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteJob.java @@ -7,12 +7,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @JsonIgnoreProperties(ignoreUnknown = true) @Builder @NoArgsConstructor @AllArgsConstructor -public class BuildKiteJob { +public class BuildKiteJob implements Serializable { private String name; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteOrganizationsInfo.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteOrganizationsInfo.java index 80e5a66a9b..c643b710f7 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteOrganizationsInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteOrganizationsInfo.java @@ -6,12 +6,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class BuildKiteOrganizationsInfo { +public class BuildKiteOrganizationsInfo implements Serializable { private String name; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKitePipelineDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKitePipelineDTO.java index 9acdab32f6..4c6e0ac6bf 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKitePipelineDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKitePipelineDTO.java @@ -7,6 +7,7 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.Date; import java.util.List; @@ -15,7 +16,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class BuildKitePipelineDTO { +public class BuildKitePipelineDTO implements Serializable { private String id; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteTokenInfo.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteTokenInfo.java index b217c3fa13..ae65912e54 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteTokenInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteTokenInfo.java @@ -6,6 +6,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.List; @AllArgsConstructor @@ -13,7 +14,7 @@ @Getter @Builder @JsonIgnoreProperties(ignoreUnknown = true) -public class BuildKiteTokenInfo { +public class BuildKiteTokenInfo implements Serializable { private List scopes; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/CreatedByDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/CreatedByDTO.java index 39cd559501..5c32e9e343 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/CreatedByDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/CreatedByDTO.java @@ -6,6 +6,7 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.Date; @Data @@ -13,7 +14,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class CreatedByDTO { +public class CreatedByDTO implements Serializable { private String id; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/EnvDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/EnvDTO.java index 489e21e75f..011eaa1112 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/EnvDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/EnvDTO.java @@ -5,10 +5,12 @@ import lombok.Builder; import lombok.Data; +import java.io.Serializable; + @Data @Builder @AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class EnvDTO { +public class EnvDTO implements Serializable { } diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderDTO.java index 38522b3cb1..cdaa576862 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderDTO.java @@ -7,12 +7,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class ProviderDTO { +public class ProviderDTO implements Serializable { private String id; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderSettingsDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderSettingsDTO.java index b6aaa2eaf5..ff8c893866 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderSettingsDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/ProviderSettingsDTO.java @@ -7,12 +7,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class ProviderSettingsDTO { +public class ProviderSettingsDTO implements Serializable { @JsonProperty("trigger_mode") private String triggerMode; diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/StepsDTO.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/StepsDTO.java index 00c9323201..df1c5d9c2a 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/StepsDTO.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/StepsDTO.java @@ -7,12 +7,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) -public class StepsDTO { +public class StepsDTO implements Serializable { private String type; diff --git a/backend/src/main/java/heartbeat/config/CacheConfig.java b/backend/src/main/java/heartbeat/config/CacheConfig.java index 295eaa5807..0b5c196b44 100644 --- a/backend/src/main/java/heartbeat/config/CacheConfig.java +++ b/backend/src/main/java/heartbeat/config/CacheConfig.java @@ -7,11 +7,13 @@ import heartbeat.client.dto.board.jira.JiraBoardVerifyDTO; import heartbeat.client.dto.board.jira.StatusSelfDTO; import java.time.Duration; +import java.util.List; import javax.cache.CacheManager; import javax.cache.Caching; import javax.cache.spi.CachingProvider; import heartbeat.client.dto.board.jira.HolidaysResponseDTO; +import heartbeat.client.dto.pipeline.buildkite.BuildKiteTokenInfo; import lombok.val; import org.ehcache.config.builders.CacheConfigurationBuilder; import org.ehcache.config.builders.ExpiryPolicyBuilder; @@ -39,6 +41,10 @@ public CacheManager ehCacheManager() { cacheManager.createCache("boardProject", getCacheConfiguration(JiraBoardProject.class)); cacheManager.createCache("jiraCards", getCacheConfiguration(String.class)); cacheManager.createCache("holidayResult", getCacheConfiguration(HolidaysResponseDTO.class)); + cacheManager.createCache("tokenInfo", getCacheConfiguration(BuildKiteTokenInfo.class)); + cacheManager.createCache("buildKiteOrganizationInfo", getCacheConfiguration(List.class)); + cacheManager.createCache("pipelineInfo", getCacheConfiguration(List.class)); + cacheManager.createCache("pipelineStepsInfo", getCacheConfiguration(List.class)); return cacheManager; } From 1e26b6e94451a7a03111a01c3d969e36ef92a922 Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Mon, 8 Jan 2024 16:33:50 +0800 Subject: [PATCH 10/11] ADM-675: [backend]feat: [backend]feat:config cache for all method in GitHubFeignClient --- .../src/main/java/heartbeat/client/GitHubFeignClient.java | 7 +++++++ .../java/heartbeat/client/dto/codebase/github/Author.java | 4 +++- .../heartbeat/client/dto/codebase/github/AuthorOuter.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Base.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Comment.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Commit.java | 4 +++- .../heartbeat/client/dto/codebase/github/CommitInfo.java | 3 ++- .../java/heartbeat/client/dto/codebase/github/Commits.java | 4 +++- .../heartbeat/client/dto/codebase/github/Committer.java | 4 +++- .../client/dto/codebase/github/CommitterOuter.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/File.java | 4 +++- .../dto/codebase/github/GitHubOrganizationsInfo.java | 4 +++- .../heartbeat/client/dto/codebase/github/GitHubRepo.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Head.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Html.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Issue.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/License.java | 4 +++- .../client/dto/codebase/github/LinkCollection.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Owner.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Parent.java | 4 +++- .../client/dto/codebase/github/PullRequestInfo.java | 3 ++- .../java/heartbeat/client/dto/codebase/github/Repo.java | 5 ++--- .../client/dto/codebase/github/ReviewComment.java | 4 +++- .../client/dto/codebase/github/ReviewComments.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Self.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Stats.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Status.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/Tree.java | 4 +++- .../java/heartbeat/client/dto/codebase/github/User.java | 4 +++- .../heartbeat/client/dto/codebase/github/Verification.java | 4 +++- backend/src/main/java/heartbeat/config/CacheConfig.java | 7 +++++++ 31 files changed, 98 insertions(+), 31 deletions(-) diff --git a/backend/src/main/java/heartbeat/client/GitHubFeignClient.java b/backend/src/main/java/heartbeat/client/GitHubFeignClient.java index 75ad40fc57..2b6548292b 100644 --- a/backend/src/main/java/heartbeat/client/GitHubFeignClient.java +++ b/backend/src/main/java/heartbeat/client/GitHubFeignClient.java @@ -5,6 +5,7 @@ import heartbeat.client.dto.codebase.github.GitHubRepo; import heartbeat.client.dto.codebase.github.PullRequestInfo; import heartbeat.decoder.GitHubFeignClientDecoder; +import org.springframework.cache.annotation.Cacheable; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; @@ -24,32 +25,38 @@ public interface GitHubFeignClient { void verifyCanReadTargetBranch(@PathVariable String repository, @PathVariable String branchName, @RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "githubOrganizationInfo", key = "#token") @GetMapping(path = "/user/orgs") @ResponseStatus(HttpStatus.OK) @Deprecated List getGithubOrganizationsInfo(@RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "githubAllRepos", key = "#token") @GetMapping(path = "/user/repos") @ResponseStatus(HttpStatus.OK) @Deprecated List getAllRepos(@RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "githubRepos", key = "#organizationName") @GetMapping(path = "/orgs/{organizationName}/repos") @ResponseStatus(HttpStatus.OK) @Deprecated List getReposByOrganizationName(@PathVariable String organizationName, @RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "commitInfo", key = "#repository+'-'+#commitId") @GetMapping(path = "/repos/{repository}/commits/{commitId}") @ResponseStatus(HttpStatus.OK) CommitInfo getCommitInfo(@PathVariable String repository, @PathVariable String commitId, @RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "pullRequestCommitInfo", key = "#repository+'-'+#mergedPullNumber") @GetMapping(path = "/repos/{repository}/pulls/{mergedPullNumber}/commits") @ResponseStatus(HttpStatus.OK) List getPullRequestCommitInfo(@PathVariable String repository, @PathVariable String mergedPullNumber, @RequestHeader("Authorization") String token); + @Cacheable(cacheNames = "pullRequestListInfo", key = "#repository+'-'+#deployId") @GetMapping(path = "/repos/{repository}/commits/{deployId}/pulls") @ResponseStatus(HttpStatus.OK) List getPullRequestListInfo(@PathVariable String repository, @PathVariable String deployId, diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Author.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Author.java index 415198e2ac..da481a3f19 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Author.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Author.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Author { +public class Author implements Serializable { private String name; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/AuthorOuter.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/AuthorOuter.java index 8be0cc0528..566a81519c 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/AuthorOuter.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/AuthorOuter.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class AuthorOuter { +public class AuthorOuter implements Serializable { private String login; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Base.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Base.java index ac96c750e0..e2bc62608b 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Base.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Base.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Base { +public class Base implements Serializable { private String label; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Comment.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Comment.java index ff97ba624b..84d4dfbfcb 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Comment.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Comment.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Comment { +public class Comment implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Commit.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Commit.java index 6309b1b558..2af13c7134 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Commit.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Commit.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Commit { +public class Commit implements Serializable { private Author author; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitInfo.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitInfo.java index 1f6a55e9a1..6fdf70289a 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitInfo.java @@ -6,13 +6,14 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.List; @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class CommitInfo { +public class CommitInfo implements Serializable { private String sha; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Commits.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Commits.java index 1db391606a..6a6087d8fc 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Commits.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Commits.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Commits { +public class Commits implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Committer.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Committer.java index 50fd43c57c..136c19dad6 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Committer.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Committer.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Committer { +public class Committer implements Serializable { private String name; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitterOuter.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitterOuter.java index becaf04070..23eb7d5cef 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitterOuter.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/CommitterOuter.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class CommitterOuter { +public class CommitterOuter implements Serializable { private String login; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/File.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/File.java index 8f7b7c3330..5279069781 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/File.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/File.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class File { +public class File implements Serializable { private String sha; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubOrganizationsInfo.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubOrganizationsInfo.java index d7833728ea..a16ecdf8ce 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubOrganizationsInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubOrganizationsInfo.java @@ -6,12 +6,14 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.io.Serializable; + @AllArgsConstructor @NoArgsConstructor @Getter @Builder @JsonIgnoreProperties(ignoreUnknown = true) -public class GitHubOrganizationsInfo { +public class GitHubOrganizationsInfo implements Serializable { private String login; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubRepo.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubRepo.java index 97d4f42186..e806cf8b88 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubRepo.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/GitHubRepo.java @@ -7,12 +7,14 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.io.Serializable; + @AllArgsConstructor @NoArgsConstructor @Getter @Builder @JsonIgnoreProperties(ignoreUnknown = true) -public class GitHubRepo { +public class GitHubRepo implements Serializable { @JsonProperty("html_url") private String htmlUrl; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Head.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Head.java index c8666a1b87..dab44a8da7 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Head.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Head.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Head { +public class Head implements Serializable { private String label; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Html.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Html.java index 4323338dbd..c9f7b0d42c 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Html.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Html.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Html { +public class Html implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Issue.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Issue.java index fe24e2e905..b935061bb3 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Issue.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Issue.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Issue { +public class Issue implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/License.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/License.java index 74350cf99d..46ce69b932 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/License.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/License.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class License { +public class License implements Serializable { private String key; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/LinkCollection.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/LinkCollection.java index e6d588c70c..5caf031822 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/LinkCollection.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/LinkCollection.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class LinkCollection { +public class LinkCollection implements Serializable { private Self self; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Owner.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Owner.java index a33378eec5..24fd8a1a92 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Owner.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Owner.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Owner { +public class Owner implements Serializable { private String login; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Parent.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Parent.java index 67523769c8..291a39b40f 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Parent.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Parent.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Parent { +public class Parent implements Serializable { private String sha; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/PullRequestInfo.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/PullRequestInfo.java index b5bf8e20de..f0672a2b36 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/PullRequestInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/PullRequestInfo.java @@ -7,6 +7,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.List; @Data @@ -14,7 +15,7 @@ @NoArgsConstructor @AllArgsConstructor @Getter -public class PullRequestInfo { +public class PullRequestInfo implements Serializable { private String url; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Repo.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Repo.java index 94991be6a9..ee55d42092 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Repo.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Repo.java @@ -1,20 +1,19 @@ package heartbeat.client.dto.codebase.github; import com.fasterxml.jackson.annotation.JsonProperty; -import heartbeat.client.dto.codebase.github.License; -import heartbeat.client.dto.codebase.github.Owner; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.List; @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Repo { +public class Repo implements Serializable { private Integer id; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComment.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComment.java index 6828b6b3db..52d50eff3e 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComment.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComment.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class ReviewComment { +public class ReviewComment implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComments.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComments.java index f71d3eef76..b040cf3f29 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComments.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/ReviewComments.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class ReviewComments { +public class ReviewComments implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Self.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Self.java index b6615ae9ad..20aa3b6afb 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Self.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Self.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Self { +public class Self implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Stats.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Stats.java index 8a35608185..ce1dd29918 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Stats.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Stats.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Stats { +public class Stats implements Serializable { private Integer total; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Status.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Status.java index 4f8e827c97..59d115d7f9 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Status.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Status.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Status { +public class Status implements Serializable { private String href; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Tree.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Tree.java index db4d8b9936..2bb563eed6 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Tree.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Tree.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Tree { +public class Tree implements Serializable { private String sha; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/User.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/User.java index 181c9e4c3e..4d82094d20 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/User.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/User.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class User { +public class User implements Serializable { private String login; diff --git a/backend/src/main/java/heartbeat/client/dto/codebase/github/Verification.java b/backend/src/main/java/heartbeat/client/dto/codebase/github/Verification.java index abfcb34f66..5991419b87 100644 --- a/backend/src/main/java/heartbeat/client/dto/codebase/github/Verification.java +++ b/backend/src/main/java/heartbeat/client/dto/codebase/github/Verification.java @@ -5,11 +5,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @Builder @NoArgsConstructor @AllArgsConstructor -public class Verification { +public class Verification implements Serializable { private Boolean verified; diff --git a/backend/src/main/java/heartbeat/config/CacheConfig.java b/backend/src/main/java/heartbeat/config/CacheConfig.java index 0b5c196b44..7c777f87eb 100644 --- a/backend/src/main/java/heartbeat/config/CacheConfig.java +++ b/backend/src/main/java/heartbeat/config/CacheConfig.java @@ -13,6 +13,7 @@ import javax.cache.spi.CachingProvider; import heartbeat.client.dto.board.jira.HolidaysResponseDTO; +import heartbeat.client.dto.codebase.github.CommitInfo; import heartbeat.client.dto.pipeline.buildkite.BuildKiteTokenInfo; import lombok.val; import org.ehcache.config.builders.CacheConfigurationBuilder; @@ -45,6 +46,12 @@ public CacheManager ehCacheManager() { cacheManager.createCache("buildKiteOrganizationInfo", getCacheConfiguration(List.class)); cacheManager.createCache("pipelineInfo", getCacheConfiguration(List.class)); cacheManager.createCache("pipelineStepsInfo", getCacheConfiguration(List.class)); + cacheManager.createCache("githubOrganizationInfo", getCacheConfiguration(List.class)); + cacheManager.createCache("githubAllRepos", getCacheConfiguration(List.class)); + cacheManager.createCache("githubRepos", getCacheConfiguration(List.class)); + cacheManager.createCache("commitInfo", getCacheConfiguration(CommitInfo.class)); + cacheManager.createCache("pullRequestCommitInfo", getCacheConfiguration(List.class)); + cacheManager.createCache("pullRequestListInfo", getCacheConfiguration(List.class)); return cacheManager; } From 0669c5dec7af4867379e4a8ce179a9a7a3a8e7b7 Mon Sep 17 00:00:00 2001 From: Shiqi Yuan Date: Wed, 10 Jan 2024 17:15:59 +0800 Subject: [PATCH 11/11] ADM-675: [backend]fix:fix the serialize exception in getPipelineStepsInfo method --- .../client/dto/pipeline/buildkite/BuildKiteBuildInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java index 4afadd19f6..1f17bc75eb 100644 --- a/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java +++ b/backend/src/main/java/heartbeat/client/dto/pipeline/buildkite/BuildKiteBuildInfo.java @@ -39,7 +39,7 @@ public class BuildKiteBuildInfo implements Serializable { @AllArgsConstructor @NoArgsConstructor @Builder - public static class Author { + public static class Author implements Serializable { private String userName;