[SIS-xxx] slight adaptions for new donation structure

This commit is contained in:
Sheldan
2025-12-07 13:40:52 +01:00
parent 29bb752367
commit a47f399d36
3 changed files with 8 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.RoundingMode;
import java.util.List;
@RestController
@@ -50,6 +51,11 @@ public class DebraDonationStatusController {
return CampaignInfo
.builder()
.donationCount(donationResponse.getDonationCount())
.collected(donationResponse.getCurrentDonationAmount())
.target(donationResponse.getDonationAmountGoal())
.percent(donationResponse.getCurrentDonationAmount().divide(donationResponse.getDonationAmountGoal(), RoundingMode.CEILING))
.currency("")
.build();
}
}

View File

@@ -4,17 +4,13 @@ import lombok.Builder;
import lombok.Getter;
import java.math.BigDecimal;
import java.math.BigInteger;
@Builder
@Getter
public class CampaignInfo {
private BigInteger donationCount;
private Integer donationCount;
private BigDecimal collected;
private BigDecimal target;
private String currency;
private String slug;
private String displayName;
private BigDecimal collectedNet;
private BigDecimal percent;
}

View File

@@ -239,7 +239,7 @@ def rendering_donation_image(donation_stats, parameters):
height = parameters.font_size
it = 0
for donation in donations_to_draw:
name = donation['firstName'] if not donation['anonymous'] else 'anonym'
name = donation['name'] if not donation['anonymous'] and 'name' in donation else 'anonym'
d1.text((0, height * it), f"{donation['donationAmount']}€ von {name}", fill=parameters.color, font=font)
it += 1
return flask_utils.serve_pil_image(img)