Skip to content

Commit 01e4645

Browse files
emir-karabegwaleedlatif1
authored andcommitted
improvement: addressed comments
1 parent 8afd5c7 commit 01e4645

File tree

3 files changed

+58
-400
lines changed

3 files changed

+58
-400
lines changed

apps/sim/app/api/workspaces/[id]/metrics/executions/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const QueryParamsSchema = z.object({
1616
folderIds: z.string().optional(),
1717
triggers: z.string().optional(),
1818
level: z.string().optional(), // Supports comma-separated values: 'error,running'
19+
allTime: z
20+
.enum(['true', 'false'])
21+
.optional()
22+
.transform((v) => v === 'true'),
1923
})
2024

2125
export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
@@ -34,7 +38,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
3438
? new Date(qp.startTime)
3539
: new Date(end.getTime() - 24 * 60 * 60 * 1000)
3640

37-
const isAllTime = start.getTime() < 86400000
41+
const isAllTime = qp.allTime === true
3842

3943
if (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime())) {
4044
return NextResponse.json({ error: 'Invalid time range' }, { status: 400 })

apps/sim/app/workspace/[workspaceId]/logs/components/logs-toolbar/logs-toolbar.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useCallback, useEffect, useMemo, useState } from 'react'
3+
import { useCallback, useMemo } from 'react'
44
import { ArrowUp, Bell, Library, Loader2, MoreHorizontal, RefreshCw } from 'lucide-react'
55
import { useParams } from 'next/navigation'
66
import {
@@ -19,6 +19,7 @@ import { getTriggerOptions } from '@/lib/logs/get-trigger-options'
1919
import { getBlock } from '@/blocks/registry'
2020
import { useFolderStore } from '@/stores/folders/store'
2121
import { useFilterStore } from '@/stores/logs/filters/store'
22+
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
2223
import { AutocompleteSearch } from './components/search'
2324

2425
const CORE_TRIGGER_TYPES = ['manual', 'api', 'schedule', 'chat', 'webhook'] as const
@@ -155,22 +156,17 @@ export function LogsToolbar({
155156
} = useFilterStore()
156157
const folders = useFolderStore((state) => state.folders)
157158

158-
const [workflows, setWorkflows] = useState<Array<{ id: string; name: string; color: string }>>([])
159-
160-
useEffect(() => {
161-
const fetchWorkflows = async () => {
162-
try {
163-
const res = await fetch(`/api/workflows?workspaceId=${encodeURIComponent(workspaceId)}`)
164-
if (res.ok) {
165-
const body = await res.json()
166-
setWorkflows(Array.isArray(body?.data) ? body.data : [])
167-
}
168-
} catch {
169-
setWorkflows([])
170-
}
171-
}
172-
if (workspaceId) fetchWorkflows()
173-
}, [workspaceId])
159+
// Use the same workflow source as the dashboard's WorkflowsList
160+
const allWorkflows = useWorkflowRegistry((state) => state.workflows)
161+
162+
// Transform registry workflows to the format needed for combobox options
163+
const workflows = useMemo(() => {
164+
return Object.values(allWorkflows).map((w) => ({
165+
id: w.id,
166+
name: w.name,
167+
color: w.color,
168+
}))
169+
}, [allWorkflows])
174170

175171
const folderList = useMemo(() => {
176172
return Object.values(folders).filter((f) => f.workspaceId === workspaceId)

0 commit comments

Comments
 (0)