-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add execution labels (#1190)
* Add Execution labels * Execution now features labels as the Flow does. * The labels are passed in the same way the Flow inputs. * The label names are prefixed with `label-`. * Executions can be filtered using the labels. Room for improvement: * Index the labels within DB. * Rework the labels/inputs passing - use a custom binding? * Add a label filter to the Execution UI. close #906 Co-authored-by: Loïc Mathieu <loikeseke@gmail.com>
- Loading branch information
1 parent
fa52d5e
commit e467c2b
Showing
19 changed files
with
237 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
jdbc-h2/src/main/java/io/kestra/repository/h2/H2ExecutionRepositoryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.kestra.repository.h2; | ||
|
||
import io.kestra.core.models.executions.Execution; | ||
import io.kestra.jdbc.AbstractJdbcRepository; | ||
import org.jooq.Condition; | ||
import org.jooq.Field; | ||
import org.jooq.impl.DSL; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public abstract class H2ExecutionRepositoryService { | ||
public static Condition findCondition(AbstractJdbcRepository<Execution> jdbcRepository, String query, Map<String, String> labels) { | ||
List<Condition> conditions = new ArrayList<>(); | ||
|
||
if (query != null) { | ||
conditions.add(jdbcRepository.fullTextCondition(List.of("fulltext"), query)); | ||
} | ||
|
||
if (labels != null) { | ||
labels.forEach((key, value) -> { | ||
Field<String> field = DSL.field("JQ_STRING(\"value\", '.labels." + key + "')", String.class); | ||
|
||
if (value == null) { | ||
conditions.add(field.isNotNull()); | ||
} else { | ||
conditions.add(field.eq(value)); | ||
} | ||
}); | ||
} | ||
|
||
return conditions.size() == 0 ? DSL.trueCondition() : DSL.and(conditions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
jdbc-mysql/src/main/java/io/kestra/repository/mysql/MysqlExecutionRepositoryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.kestra.repository.mysql; | ||
|
||
import io.kestra.core.models.executions.Execution; | ||
import io.kestra.jdbc.AbstractJdbcRepository; | ||
import org.jooq.Condition; | ||
import org.jooq.Field; | ||
import org.jooq.impl.DSL; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public abstract class MysqlExecutionRepositoryService { | ||
public static Condition findCondition(AbstractJdbcRepository<Execution> jdbcRepository, String query, Map<String, String> labels) { | ||
List<Condition> conditions = new ArrayList<>(); | ||
|
||
if (query != null) { | ||
conditions.add(jdbcRepository.fullTextCondition(Arrays.asList("namespace", "id"), query)); | ||
} | ||
|
||
if (labels != null) { | ||
labels.forEach((key, value) -> { | ||
Field<String> field = DSL.field("JSON_VALUE(value, '$.labels." + key + "' NULL ON EMPTY)", String.class); | ||
|
||
if (value == null) { | ||
conditions.add(field.isNotNull()); | ||
} else { | ||
conditions.add(field.eq(value)); | ||
} | ||
}); | ||
} | ||
|
||
return conditions.size() == 0 ? DSL.trueCondition() : DSL.and(conditions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.