refactor(queries/get-executions): use createdAt in filters
This commit is contained in:
@@ -7,7 +7,7 @@ import paginate from '../../helpers/pagination';
|
|||||||
type Filters = {
|
type Filters = {
|
||||||
flowId?: string;
|
flowId?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
updatedAt?: {
|
createdAt?: {
|
||||||
from?: string;
|
from?: string;
|
||||||
to?: string;
|
to?: string;
|
||||||
};
|
};
|
||||||
@@ -46,7 +46,7 @@ const getExecutions = async (
|
|||||||
.joinRelated('executionSteps as execution_steps')
|
.joinRelated('executionSteps as execution_steps')
|
||||||
.select('executions.*', raw(selectStatusStatement))
|
.select('executions.*', raw(selectStatusStatement))
|
||||||
.groupBy('executions.id')
|
.groupBy('executions.id')
|
||||||
.orderBy('updated_at', 'desc');
|
.orderBy('created_at', 'desc');
|
||||||
|
|
||||||
const computedExecutions = Execution
|
const computedExecutions = Execution
|
||||||
.query()
|
.query()
|
||||||
@@ -66,24 +66,24 @@ const getExecutions = async (
|
|||||||
computedExecutions.where('executions.status', filters.status);
|
computedExecutions.where('executions.status', filters.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filters?.updatedAt) {
|
if (filters?.createdAt) {
|
||||||
const updatedAtFilter = filters.updatedAt;
|
const createdAtFilter = filters.createdAt;
|
||||||
if (updatedAtFilter.from) {
|
if (createdAtFilter.from) {
|
||||||
const isoFromDateTime = DateTime
|
const isoFromDateTime = DateTime
|
||||||
.fromMillis(
|
.fromMillis(
|
||||||
parseInt(updatedAtFilter.from, 10)
|
parseInt(createdAtFilter.from, 10)
|
||||||
)
|
)
|
||||||
.toISO();
|
.toISO();
|
||||||
computedExecutions.where('executions.updated_at', '>=', isoFromDateTime);
|
computedExecutions.where('executions.created_at', '>=', isoFromDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updatedAtFilter.to) {
|
if (createdAtFilter.to) {
|
||||||
const isoToDateTime = DateTime
|
const isoToDateTime = DateTime
|
||||||
.fromMillis(
|
.fromMillis(
|
||||||
parseInt(updatedAtFilter.to, 10)
|
parseInt(createdAtFilter.to, 10)
|
||||||
)
|
)
|
||||||
.toISO();
|
.toISO();
|
||||||
computedExecutions.where('executions.updated_at', '<=', isoToDateTime);
|
computedExecutions.where('executions.created_at', '<=', isoToDateTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -799,14 +799,14 @@ type Notification {
|
|||||||
description: String
|
description: String
|
||||||
}
|
}
|
||||||
|
|
||||||
input ExecutionUpdatedAtFilterInput {
|
input ExecutionCreatedAtFilterInput {
|
||||||
from: String
|
from: String
|
||||||
to: String
|
to: String
|
||||||
}
|
}
|
||||||
|
|
||||||
input ExecutionFiltersInput {
|
input ExecutionFiltersInput {
|
||||||
flowId: String
|
flowId: String
|
||||||
updatedAt: ExecutionUpdatedAtFilterInput
|
createdAt: ExecutionCreatedAtFilterInput
|
||||||
status: String
|
status: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user