@ExecuteOn(TaskExecutors.IO)
    @Post(uri = "/unlock/by-query")
    @Operation(tags = {"Triggers"}, summary = "Unlock triggers by query parameters")
    public MutableHttpResponse<?> unlockByQuery(
        @Parameter(description = "A string filter") @Nullable @QueryValue(value = "q") String query,
        @Parameter(description = "A namespace filter prefix") @Nullable @QueryValue String namespace
    ) {
        Integer count = triggerRepository
            .find(query, tenantService.resolveTenant(), namespace)
            .filter(trigger -> trigger.getExecutionId() != null || trigger.getEvaluateRunningDate() != null)
            .map(trigger -> {
                try {
                    this.unlock(trigger.getNamespace(), trigger.getFlowId(), trigger.getTriggerId());
                }
                // When doing bulk action, we ignore that a trigger can't be unlocked
                catch (IllegalStateException ignored) {
                    return 0;
                }
                return 1;
            })
            .reduce(Integer::sum)
            .blockOptional()
            .orElse(0);

        return HttpResponse.ok(BulkResponse.builder().count(count).build());
    }
@Test
    void unlockByQuery() {
        Trigger triggerLock = Trigger.builder()
            .flowId(IdUtils.create())
            .namespace("io.kestra.unittest")
            .triggerId(IdUtils.create())
            .executionId(IdUtils.create())
            .build();

        Trigger triggerNotLock = Trigger.builder()
            .flowId(IdUtils.create())
            .namespace("io.kestra.unittest")
            .triggerId(IdUtils.create())
            .build();

        jdbcTriggerRepository.save(triggerLock);
        jdbcTriggerRepository.save(triggerNotLock);

        BulkResponse bulkResponse = client.toBlocking().retrieve(HttpRequest.POST("/api/v1/triggers/unlock/by-query?namespace=io.kestra.unittest", null), BulkResponse.class);

        assertThat(bulkResponse.getCount(), is(1));
    }