@@ -55,7 +55,7 @@ protected void resolveUserPredictions(double returnRatioForWin, @NonNull String
5555 SET
5656 `PredictionCnt`=`PredictionCnt`+1,
5757 `WinCnt`=`WinCnt`+?,
58- `WinRate`=`WinCnt`/`PredictionCnt`,
58+ `WinRate`=( `WinCnt` + ?) /`PredictionCnt`,
5959 `ReturnOnInvestment`=`ReturnOnInvestment`+?
6060 WHERE `ID`=? AND `ChannelID`=?""" )
6161 ){
@@ -65,20 +65,17 @@ protected void resolveUserPredictions(double returnRatioForWin, @NonNull String
6565 try (var result = getOpenPredictionStmt .executeQuery ()){
6666 while (result .next ()){
6767 var userPrediction = Converters .convertUserPrediction (result );
68- if (badge .equals (userPrediction .getBadge ())){
69- updatePredictionUserStmt .setInt (1 , 1 );
70- updatePredictionUserStmt .setDouble (2 , returnOnInvestment );
71- }
72- else {
73- updatePredictionUserStmt .setInt (1 , 0 );
74- updatePredictionUserStmt .setDouble (2 , -1 );
75- }
76- updatePredictionUserStmt .setInt (3 , userPrediction .getUserId ());
77- updatePredictionUserStmt .setString (4 , userPrediction .getChannelId ());
68+ boolean isWinner = badge .equals (userPrediction .getBadge ());
69+
70+ updatePredictionUserStmt .setInt (1 , isWinner ? 1 : 0 );
71+ updatePredictionUserStmt .setInt (2 , isWinner ? 1 : 0 );
72+ updatePredictionUserStmt .setDouble (3 , isWinner ? returnOnInvestment : -1 );
73+ updatePredictionUserStmt .setInt (4 , userPrediction .getUserId ());
74+ updatePredictionUserStmt .setString (5 , userPrediction .getChannelId ());
7875 updatePredictionUserStmt .addBatch ();
7976 }
8077 updatePredictionUserStmt .executeBatch ();
8178 }
8279 }
8380 }
84- }
81+ }
0 commit comments