Skip to content

Commit

Permalink
Merge pull request #41 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 23, 2023
2 parents b27a260 + b8e8979 commit 3663afc
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.*;

import static gwangjang.server.domain.contents.presentation.constant.ContentsResponse.GET_MY_CONTENTS;
import static gwangjang.server.domain.contents.presentation.constant.ContentsResponseMessage.GET_CONTENTS_SUCCESS;
Expand Down Expand Up @@ -84,12 +82,19 @@ 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, ""));
result.add(new BubbleFrontRes(6L, null, 0L, ""));

Set<Long> usedRandomValues = new HashSet<>(); // to track used random values

for (BubbleChartRes bubbleChart : bubbleChartList) {
Long x = Long.parseLong(bubbleChart.getDate());
Long y = (long) (rand.nextInt(10) + 1); // Random value between 1 and 10
Long y;

// Generate a unique random value
do {
y = (long) (rand.nextInt(10) + 1);
} while (!usedRandomValues.add(y));

Long z = bubbleChart.getRank();
String name = bubbleChart.getKeyword();

Expand Down

0 comments on commit 3663afc

Please sign in to comment.