Skip to content

Commit

Permalink
feat, fix : add treated and untreated filters
Browse files Browse the repository at this point in the history
  • Loading branch information
annadiplacido committed Oct 17, 2024
1 parent a55cf28 commit 31377d2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ public Response markAlertAsTreated(@PathParam("alertId") String alertId) throws
.orElseThrow(() -> new ResourceNotFoundException("Alert with ID " + alertId + " not found."));
}

@GET
@Path("/treated")
@Produces(MediaType.APPLICATION_JSON)
public List<Alert> getTreatedAlerts() {
return alertRepository.findByTreatedStatus(true);
}

@GET
@Path("/untreated")
@Produces(MediaType.APPLICATION_JSON)
public List<Alert> getUntreatedAlerts() {
return alertRepository.findByTreatedStatus(false);
}

@Scheduled(every = "10m")
void checkUnresolvedAlerts() {
List<Alert> unresolvedAlerts = alertRepository.findUnresolvedAlerts();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

public record AlertDTO(
@NotNull(message = "Time must not be null")
@NotEmpty(message = "Time must not be empty")
Date time,

@NotNull(message = "Alert type must not be null")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,58 +49,5 @@ public Alert(String type, String message, String gatewayId, int value) {
}


public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public String getGatewayId() {
return gatewayId;
}

public void setGatewayId(String gatewayId) {
this.gatewayId = gatewayId;
}

public LocalDateTime getTimestamp() {
return timestamp;
}

public void setTimestamp(LocalDateTime timestamp) {
this.timestamp = timestamp;
}

public boolean isTreated() {
return treated;
}

public void setTreated(boolean treated) {
this.treated = treated;
}

public int getValue() {
return value;
}

public void setValue(int value) {
this.value = value;
}
public Severity getSeverity() {
return severity;
}

public void setSeverity(Severity severity) {
this.severity = severity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public List<Alert> findUnresolvedAlerts() {
return list("treated = false");
}

public List<Alert> findByTreatedStatus(boolean treated) {
return list("treated", treated);
}

public List<Alert> findByGatewayId(String gatewayId) {
return find("gatewayId", gatewayId).list();
}
Expand Down

0 comments on commit 31377d2

Please sign in to comment.