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

feat(): filter state on dashboard and graph on execution list #4507

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
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 @@ -8,7 +8,6 @@
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;

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

Expand Down Expand Up @@ -36,8 +35,8 @@ public static ExecutionUsage of(final String tenantId,
from,
to,
DateUtils.GroupType.DAY,
true
);
null,
true);
} catch (UnsupportedOperationException ignored) {

}
Expand All @@ -51,8 +50,8 @@ public static ExecutionUsage of(final String tenantId,
from,
to,
DateUtils.GroupType.DAY,
false
))
null,
false))
.dailyTaskRunsCount(dailyTaskRunsCount)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
import io.kestra.core.models.flows.State;
import io.kestra.core.utils.DateUtils;
import io.micronaut.data.model.Pageable;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import reactor.core.publisher.Flux;

import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotNull;
import reactor.core.publisher.Flux;

public interface ExecutionRepositoryInterface extends SaveRepositoryInterface<Execution> {
Boolean isTaskRunEnabled();
Expand Down Expand Up @@ -122,6 +122,7 @@ List<DailyExecutionStatistics> dailyStatistics(
@Nullable ZonedDateTime startDate,
@Nullable ZonedDateTime endDate,
@Nullable DateUtils.GroupType groupBy,
List<State.Type> state,
boolean isTaskRun
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ protected void dailyStatistics() throws InterruptedException {
ZonedDateTime.now().minusDays(10),
ZonedDateTime.now(),
null,
false
);
null,
false);

assertThat(result.size(), is(11));
assertThat(result.get(10).getExecutionCounts().size(), is(11));
Expand Down Expand Up @@ -456,8 +456,8 @@ protected void taskRunsDailyStatistics() {
ZonedDateTime.now().minusDays(10),
ZonedDateTime.now(),
null,
true
);
null,
true);

assertThat(result.size(), is(11));
assertThat(result.get(10).getExecutionCounts().size(), is(11));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ public List<DailyExecutionStatistics> dailyStatisticsForAllTenants(
null,
startDate,
endDate,
groupBy
groupBy,
null
);

return dailyStatisticsQueryMapRecord(
Expand All @@ -348,6 +349,7 @@ public List<DailyExecutionStatistics> dailyStatistics(
@Nullable ZonedDateTime startDate,
@Nullable ZonedDateTime endDate,
@Nullable DateUtils.GroupType groupBy,
@Nullable List<State.Type> states,
boolean isTaskRun
) {
if (isTaskRun) {
Expand All @@ -365,7 +367,8 @@ public List<DailyExecutionStatistics> dailyStatistics(
null,
startDate,
endDate,
groupBy
groupBy,
states
);

return dailyStatisticsQueryMapRecord(
Expand Down Expand Up @@ -414,7 +417,8 @@ private Results dailyStatisticsQueryForAllTenants(
List<FlowFilter> flows,
@Nullable ZonedDateTime startDate,
@Nullable ZonedDateTime endDate,
@Nullable DateUtils.GroupType groupBy
@Nullable DateUtils.GroupType groupBy,
@Nullable List<State.Type> state
) {
return dailyStatisticsQuery(
this.defaultFilter(),
Expand All @@ -425,7 +429,8 @@ private Results dailyStatisticsQueryForAllTenants(
flows,
startDate,
endDate,
groupBy
groupBy,
state
);
}

Expand All @@ -438,7 +443,8 @@ private Results dailyStatisticsQuery(
List<FlowFilter> flows,
@Nullable ZonedDateTime startDate,
@Nullable ZonedDateTime endDate,
@Nullable DateUtils.GroupType groupBy
@Nullable DateUtils.GroupType groupBy,
@Nullable List<State.Type> state
) {
return dailyStatisticsQuery(
this.defaultFilter(tenantId),
Expand All @@ -449,7 +455,8 @@ private Results dailyStatisticsQuery(
flows,
startDate,
endDate,
groupBy
groupBy,
state
);
}

Expand All @@ -462,7 +469,8 @@ private Results dailyStatisticsQuery(
List<FlowFilter> flows,
@Nullable ZonedDateTime startDate,
@Nullable ZonedDateTime endDate,
@Nullable DateUtils.GroupType groupBy
@Nullable DateUtils.GroupType groupBy,
@Nullable List<State.Type> state
) {
ZonedDateTime finalStartDate = startDate == null ? ZonedDateTime.now().minusDays(30) : startDate;
ZonedDateTime finalEndDate = endDate == null ? ZonedDateTime.now() : endDate;
Expand Down Expand Up @@ -491,6 +499,10 @@ private Results dailyStatisticsQuery(

select = filteringQuery(select, namespace, flowId, flows, query, null, null, null);

if (state != null) {
select = select.and(this.statesFilter(state));
}

List<Field<?>> groupFields = new ArrayList<>(fields);

groupFields.addAll(dateFields);
Expand Down Expand Up @@ -583,6 +595,7 @@ public Map<String, Map<String, List<DailyExecutionStatistics>>> dailyGroupByFlow
flows,
startDate,
endDate,
null,
null
);

Expand Down
35 changes: 33 additions & 2 deletions ui/src/components/home/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@
@update:model-value="onNamespaceSelect"
/>
</el-form-item>
<el-form-item>
<el-select
:model-value="state"
@update:model-value="onStateSelect"
clearable
filterable
multiple
:placeholder="$t('state')"
>
<el-option
v-for="item in State.allStates()"
:key="item.key"
:label="item.key"
:value="item.key"
/>
</el-select>
</el-form-item>
<el-form-item>
<date-filter
@update:is-relative="onDateFilterTypeChange"
Expand Down Expand Up @@ -156,6 +173,7 @@
import TopNavBar from "../layout/TopNavBar.vue";
import DateFilter from "../executions/date-select/DateFilter.vue";
import HomeStartup from "override/mixins/homeStartup"
import State from "../../utils/state";

export default {
mixins: [RouteContext, RestoreUrl, HomeStartup],
Expand Down Expand Up @@ -217,7 +235,8 @@
namespacesStats: undefined,
namespaceRestricted: !!this.namespace,
refreshDates: false,
canAutoRefresh: false
canAutoRefresh: false,
state: []
};
},
methods: {
Expand Down Expand Up @@ -340,7 +359,19 @@
}

this.$router.push({query: query}).then(this.load);
}
},
onStateSelect(state) {
this.state = state;
if (state && state.length > 0) {
this.$router.push({query: {...this.$route.query, state: state}});
} else {
let query = {...this.$route.query}
delete query["state"]
this.$router.push({query: query});
}

this.load(this.onDataLoaded);
},
},
computed: {
...mapState("stat", ["daily", "dailyGroupByFlow"]),
Expand Down
2 changes: 1 addition & 1 deletion ui/src/mixins/dataTableActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default {
let query = {...this.$route.query};

for (const [key, value] of Object.entries(values)) {
if (value === undefined || value === "" || value === null) {
if (value === undefined || value === "" || value === null || value.length === 0) {
delete query[key]
} else {
query[key] = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.executions.statistics.DailyExecutionStatistics;
import io.kestra.core.models.executions.statistics.LogStatistics;
import io.kestra.core.models.flows.State;
import io.kestra.core.repositories.ExecutionRepositoryInterface;
import io.kestra.core.repositories.LogRepositoryInterface;
import io.kestra.core.tenant.TenantService;
Expand Down Expand Up @@ -51,8 +52,8 @@ public List<DailyExecutionStatistics> dailyStatistics(@Body @Valid StatisticRequ
statisticRequest.startDate() != null ? statisticRequest.startDate().withZoneSameInstant(ZoneId.systemDefault()) : null,
statisticRequest.endDate() != null ? statisticRequest.endDate().withZoneSameInstant(ZoneId.systemDefault()) : null,
null,
false
);
statisticRequest.state(),
false);
}

@ExecuteOn(TaskExecutors.IO)
Expand All @@ -67,8 +68,8 @@ public List<DailyExecutionStatistics> taskRunsDailyStatistics(@Body @Valid Stati
statisticRequest.startDate() != null ? statisticRequest.startDate().withZoneSameInstant(ZoneId.systemDefault()) : null,
statisticRequest.endDate() != null ? statisticRequest.endDate().withZoneSameInstant(ZoneId.systemDefault()) : null,
null,
true
);
statisticRequest.state(),
true);
}

@ExecuteOn(TaskExecutors.IO)
Expand Down Expand Up @@ -121,7 +122,8 @@ public record StatisticRequest(
@Parameter(description = "A namespace filter prefix") @Nullable String namespace,
@Parameter(description = "A flow id filter") @Nullable String flowId,
@Parameter(description = "The start datetime, default to now") @Nullable @Format("yyyy-MM-dd'T'HH:mm[:ss][.SSS][XXX]") ZonedDateTime startDate,
@Parameter(description = "The end datetime, default to now") @Nullable @Format("yyyy-MM-dd'T'HH:mm[:ss][.SSS][XXX]")ZonedDateTime endDate
@Parameter(description = "The end datetime, default to now") @Nullable @Format("yyyy-MM-dd'T'HH:mm[:ss][.SSS][XXX]")ZonedDateTime endDate,
@Parameter(description = "the state of the execution") @Nullable List<State.Type> state
) {}

@Introspected
Expand Down
Loading