Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nzwateralerts] Fix smart water alert level #11734

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class SmartWater implements WaterWebService {
private static final String REGION_WAIKATO = "/alert-levels/waikato-district-council";
private static final String REGION_WAIPA = "/alert-levels/waipa-district-council";

private static final String PATTERN = "/assets/Alert-Level-Images/water-alert-([1-4]|no)-large.svg.*?";
private static final String PATTERN = "/assets/Alert-Level-Images/(?:water-alert-([1-4]|no)-large|(save)-wai-logo).svg.*?";
private static final Pattern REGEX = Pattern.compile(PATTERN,
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);

Expand Down Expand Up @@ -66,8 +66,10 @@ public int findWaterLevel(final String data, final String area) {

while (matches.find()) {
String level = matches.group(1);
final String altMsgs = matches.group(2);

logger.debug("Data Level {}", level);
if (level.equalsIgnoreCase("no")) {
if ("no".equalsIgnoreCase(level) || "save".equalsIgnoreCase(altMsgs)) {
logger.debug("Convert Data Level to 0");
level = "0";
}
Expand Down