Skip to content

Commit

Permalink
Merge pull request #39 from kusitms-28th-Meetup-E/feat/contents
Browse files Browse the repository at this point in the history
feat: 버블차트 API
  • Loading branch information
eojinny committed Nov 22, 2023
2 parents 84089a4 + eb14049 commit 1eae258
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public ResponseEntity<SuccessResponse<List<BubbleFrontRes>>> getBubbleChart(@Pat
List<BubbleFrontRes> result = new ArrayList<>();
Random rand = new Random();

// Add element at the beginning
result.add(new BubbleFrontRes(0L, null, 0L, ""));

for (BubbleChartRes bubbleChart : bubbleChartList) {
Long x = Long.parseLong(bubbleChart.getDate());
Long y = (long) (rand.nextInt(10) + 1); // Random value between 1 and 10
Expand All @@ -93,6 +96,12 @@ public ResponseEntity<SuccessResponse<List<BubbleFrontRes>>> getBubbleChart(@Pat
result.add(new BubbleFrontRes(x, y, z, name));
}

// Add element at the end with values from the last index
if (!bubbleChartList.isEmpty()) {
BubbleChartRes lastBubbleChart = bubbleChartList.get(bubbleChartList.size() - 1);
result.add(new BubbleFrontRes(Long.parseLong(lastBubbleChart.getDate()), null, 0L, ""));
}

return ResponseEntity.ok(SuccessResponse.create(GET_CONTENTS_SUCCESS.getMessage(), result));
}

Expand Down

0 comments on commit 1eae258

Please sign in to comment.