Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions web-studio/src/routes/tasks/-lib/task-query.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { describe, expect, it } from 'vitest'

import { buildTaskQuery } from './task-query'

describe('buildTaskQuery', () => {
it('keeps the recent task query within the server limit', () => {
expect(buildTaskQuery('24h', 'all').limit).toBe(200)
})

it('keeps the all-task query within the server limit', () => {
expect(buildTaskQuery('all', 'all').limit).toBe(200)
})
})
13 changes: 13 additions & 0 deletions web-studio/src/routes/tasks/-lib/task-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export type TaskDataScope = '24h' | 'all'

// The server validates this endpoint with `limit <= 200`.
export const TASK_QUERY_LIMIT = 200

export function buildTaskQuery(dataScope: TaskDataScope, taskType: string) {
return {
limit: TASK_QUERY_LIMIT,
status: undefined,
task_type: taskType === 'all' ? undefined : taskType,
include_archived: dataScope === 'all' ? true : undefined,
}
}
9 changes: 2 additions & 7 deletions web-studio/src/routes/tasks/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
} from '#/routes/tasks/-lib/task-record'
import type { TaskRecord, TaskStatus } from '#/routes/tasks/-lib/task-record'
import { formatTaskDuration, getTaskDate } from '#/routes/tasks/-lib/task-time'
import { buildTaskQuery } from './-lib/task-query'
import { getTaskPipelineGroups } from './-lib/task-pipeline'

export const Route = createFileRoute('/tasks')({
Expand All @@ -75,7 +76,6 @@ type TaskTypeFilter =
| 'all'

const DEFAULT_PAGE_SIZE = 20
const MAX_TASKS = 300
const PAGE_SIZE_OPTIONS = [20, 50, 100] as const
const TASK_TYPE_OPTIONS: Exclude<TaskTypeFilter, 'all'>[] = [
'session_commit',
Expand Down Expand Up @@ -116,12 +116,7 @@ async function fetchTasks(
status: TaskStatusFilter,
dataScope: TaskDataScope = '24h',
): Promise<TaskRecord[]> {
const query = {
limit: dataScope === 'all' ? 10000 : MAX_TASKS,
status: undefined,
task_type: taskType === 'all' ? undefined : taskType,
include_archived: dataScope === 'all' ? true : undefined,
}
const query = buildTaskQuery(dataScope, taskType)
try {
const result = await getOvResult<unknown>(
getTasks({
Expand Down