From 0356e1daa9abc66dbdcacd6555c8f73deb5e8e26 Mon Sep 17 00:00:00 2001 From: blaxsior Date: Fri, 23 Aug 2024 19:48:10 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[fix]=20set=20=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=EC=97=90=EC=84=9C=20=EB=8B=B9=EC=B2=A8?= =?UTF-8?q?=EC=9E=90=20=EC=88=98=EA=B0=80=200=EB=AA=85=EC=9D=BC=20?= =?UTF-8?q?=EB=95=8C=20=EC=9D=B8=EB=8D=B1=EC=8A=A4=20-1=EC=9D=84=20?= =?UTF-8?q?=ED=83=90=EC=83=89=ED=95=98=EC=97=AC=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=98=88=EC=99=B8=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?(#153)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw/component/picker/AccSumBasedWinnerPicker.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/hyundai/softeer/orange/event/draw/component/picker/AccSumBasedWinnerPicker.java b/src/main/java/hyundai/softeer/orange/event/draw/component/picker/AccSumBasedWinnerPicker.java index 29c48737..d39e6973 100644 --- a/src/main/java/hyundai/softeer/orange/event/draw/component/picker/AccSumBasedWinnerPicker.java +++ b/src/main/java/hyundai/softeer/orange/event/draw/component/picker/AccSumBasedWinnerPicker.java @@ -12,8 +12,9 @@ public class AccSumBasedWinnerPicker implements WinnerPicker { @Override public List pick(List items, long count) { long maxPickCount = Math.min(items.size(), count); - // TODO: 둘 중 하나를 선택하는 최적 조건 분석하기. - if (count - maxPickCount <= 10 || // 두 값 차이가 작을 때 + // pick count = 0이면 아무 것도 안하게 수정 + if(maxPickCount == 0) return Collections.emptyList(); + if (count - maxPickCount <= 10 ||// 두 값 차이가 작을 때 ((double) count / maxPickCount) <= 1.1 ) { return pickMany(items, maxPickCount); } else { @@ -50,6 +51,7 @@ protected List pickManyUsingSet(List targets, long count // 가중합 배열 RandomItem[] items = getAccumulatedItems(targets); List pickedTargets = new ArrayList<>(); + if(items.length == 0) return pickedTargets; long bound = items[items.length - 1].score; // 이미 선택된 대상이 존재하는 공간 Set pickedIdxSet = new HashSet<>(); From 8287bd298bfb3fcb8a992dc68317ecd54a1c3c2b Mon Sep 17 00:00:00 2001 From: blaxsior Date: Fri, 23 Aug 2024 19:50:50 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[chore]=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EB=A5=BC=20=EC=9C=84=ED=95=B4=20=EB=8C=80=EA=B8=B0=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EA=B5=AC=EC=84=B1=ED=96=88=EB=8D=98=20=EB=82=B4?= =?UTF-8?q?=EC=9A=A9=20=EC=A0=9C=EA=B1=B0=20(#153)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../orange/event/draw/service/DrawEventDrawMachine.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/hyundai/softeer/orange/event/draw/service/DrawEventDrawMachine.java b/src/main/java/hyundai/softeer/orange/event/draw/service/DrawEventDrawMachine.java index 5f1b5678..70f09d6e 100644 --- a/src/main/java/hyundai/softeer/orange/event/draw/service/DrawEventDrawMachine.java +++ b/src/main/java/hyundai/softeer/orange/event/draw/service/DrawEventDrawMachine.java @@ -33,12 +33,6 @@ public class DrawEventDrawMachine { @Async @Transactional public CompletableFuture draw(DrawEvent drawEvent) { - try{ - Thread.sleep(1000 * 5 * 1); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - long drawEventRawId = drawEvent.getId(); // 점수 계산. 추후 추첨 과정과 분리될 수도 있음. List policies = drawEvent.getPolicyList();