@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_.
65 lines (61 loc) • 2.03 kB
text/typescript
import { FlowRunsFilter, TaskRunsFilter } from '@/models/Filters'
import { SavedSearchFilter } from '@/models/SavedSearch'
import { MapFunction } from '@/services/Mapper'
export const mapSavedSearchFilterToFlowRunsFilter: MapFunction<SavedSearchFilter, FlowRunsFilter> = function(source) {
const flowIds = source.flow?.length ? source.flow : undefined
const deploymentIds = source.deployment?.length ? source.deployment : undefined
const workPoolNames = source.workPool?.length ? source.workPool : undefined
const tagNames = source.tag?.length ? source.tag : undefined
const stateNames = source.state?.length ? source.state : undefined
const { startDate, endDate } = this.map('DateRangeSelectValue', source.range, 'DateRange')
return {
flows: {
id: flowIds,
},
deployments: {
id: deploymentIds,
},
workPools: {
name: workPoolNames,
},
flowRuns: {
tags: {
name: tagNames,
},
state: {
name: stateNames,
},
expectedStartTimeAfter: startDate,
expectedStartTimeBefore: endDate,
},
}
}
export const mapSavedSearchFilterToTaskRunsFilter: MapFunction<SavedSearchFilter, TaskRunsFilter> = function(source) {
const flowIds = source.flow?.length ? source.flow : undefined
const deploymentIds = source.deployment?.length ? source.deployment : undefined
const workPoolNames = source.workPool?.length ? source.workPool : undefined
const tagNames = source.tag?.length ? source.tag : undefined
const stateNames = source.state?.length ? source.state : undefined
const { startDate, endDate } = this.map('DateRangeSelectValue', source.range, 'DateRange')
return {
flows: {
id: flowIds,
},
deployments: {
id: deploymentIds,
},
workPools: {
name: workPoolNames,
},
taskRuns: {
tags: {
name: tagNames,
},
state: {
name: stateNames,
},
expectedStartTimeAfter: startDate,
expectedStartTimeBefore: endDate,
},
}
}