Skip to content

Commit

Permalink
fix(core): Dashboard end date should apply to the execution start date
Browse files Browse the repository at this point in the history
Otherwise you would not be able to have running executions.
It is aligned with what we do for the other dashboard / filter
  • Loading branch information
loicmathieu committed Jan 28, 2025
1 parent 035f6b3 commit 82150e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.kestra.core.models.dashboards;

import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.kestra.core.models.dashboards.ColumnDescriptor;
import io.kestra.core.models.dashboards.OrderBy;
import io.kestra.core.models.dashboards.charts.DataChart;
import io.kestra.core.utils.MapUtils;
import io.kestra.core.validations.DataChartValidation;
import io.micronaut.core.annotation.AnnotationValue;
import io.micronaut.core.annotation.Introspected;
Expand Down Expand Up @@ -33,7 +34,7 @@ public boolean isValid(

List<String> violations = new ArrayList<>();

Set<String> dataColumns = dataChart.getData().getColumns().keySet();
Set<String> dataColumns = MapUtils.emptyOnNull(dataChart.getData().getColumns()).keySet();
if (dataChart.getChartOptions() != null) {
List<String> neededColumns = dataChart.getChartOptions().neededColumns();
neededColumns.forEach(column -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ public void setGlobalFilter(GlobalFilter globalFilter) {
where.removeIf(f -> f.getField().equals(Fields.LABELS));
where.add(Contains.<Executions.Fields>builder().field(Fields.LABELS).value(globalFilter.getLabels()).build());
}
if (globalFilter.getStartDate() != null) {
if (globalFilter.getStartDate() != null || globalFilter.getEndDate() != null) {
where.removeIf(f -> f.getField().equals(Fields.START_DATE));
where.add(GreaterThanOrEqualTo.<Executions.Fields>builder().field(Fields.START_DATE).value(globalFilter.getStartDate().toOffsetDateTime()).build());
}
if (globalFilter.getEndDate() != null) {
where.removeIf(f -> f.getField().equals(Fields.END_DATE));
where.add(LessThanOrEqualTo.<Executions.Fields>builder().field(Fields.END_DATE).value(globalFilter.getEndDate().toOffsetDateTime()).build());
if (globalFilter.getStartDate() != null) {
where.add(GreaterThanOrEqualTo.<Executions.Fields>builder().field(Fields.START_DATE).value(globalFilter.getStartDate().toOffsetDateTime()).build());
}
if (globalFilter.getEndDate() != null) {
where.add(LessThanOrEqualTo.<Executions.Fields>builder().field(Fields.START_DATE).value(globalFilter.getEndDate().toOffsetDateTime()).build());
}
}

this.setWhere(where);
Expand Down

0 comments on commit 82150e6

Please sign in to comment.