Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Add score logic
Browse files Browse the repository at this point in the history
  • Loading branch information
plamentotev committed Oct 22, 2023
1 parent add6090 commit 8a35e49
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@Service
public class ProductService {

public static final double BASELINE = 200.0;
private final ConsumedProductRepository consumedProducts;

private final ProfileService profileService;
Expand All @@ -32,7 +33,9 @@ public void addProduct(Long consumerId, String productCode) {

consumedProducts.save(consumedProduct);

profileService.updateScore(consumerId, consumedProduct.product().footprint());
var footprint = consumedProduct.product().footprint();
var score = BASELINE - footprint;
profileService.updateScore(consumerId, (int) score);

try {
webSocketHandler.sendLeaderBoardToAllActiveSessions();
Expand Down

0 comments on commit 8a35e49

Please sign in to comment.