@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
36 lines (29 loc) • 947 B
text/typescript
import { subSeconds } from 'date-fns'
import { FlowRunsFilter, TaskRunsFilter } from '@/models'
import { MapFunction } from '@/services/Mapper'
import { DeploymentStatsFilter } from '@/types/deployment'
export const mapDeploymentStatsFilterToFlowRunsFilter: MapFunction<DeploymentStatsFilter, FlowRunsFilter> = function(source) {
const now = new Date()
const filter: FlowRunsFilter = {
deployments: {
id: [source.deploymentId],
},
flowRuns: {
expectedStartTimeAfter: subSeconds(now, source.timeSpanInSeconds),
expectedStartTimeBefore: now,
},
}
return filter
}
export const mapDeploymentStatsFilterToTaskRunsFilter: MapFunction<DeploymentStatsFilter, TaskRunsFilter> = function(source) {
const now = new Date()
return {
flows: {
id: [source.deploymentId],
},
taskRuns: {
startTimeAfter: subSeconds(now, source.timeSpanInSeconds),
startTimeBefore: now,
},
}
}