Download references/task-status/src/utils/tasks.ts from mirasim-ai/devbrowse-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/datasets/mirasim-ai/devbrowse-bench/resolve/main/references/task-status/src/utils/tasks.ts
- Command line
-
hf download hf://datasets/mirasim-ai/devbrowse-bench/references/task-status/src/utils/tasks.ts
-
curl -L -o tasks.ts https://huggingface.co/datasets/mirasim-ai/devbrowse-bench/resolve/main/references/task-status/src/utils/tasks.ts
1.38 kB
| import type { Priority, SortKey, StatusFilter, Task, TaskStatus } from "../types"; | |
| const PRIORITY_RANK: Record<Priority, number> = { high: 0, medium: 1, low: 2 }; | |
| export function matchesFilter(task: Task, filter: StatusFilter): boolean { | |
| if (filter === "active") return task.status !== "done"; | |
| if (filter === "done") return task.status === "done"; | |
| return true; | |
| } | |
| export function countByFilter(tasks: Task[]): Record<StatusFilter, number> { | |
| return { | |
| all: tasks.length, | |
| active: tasks.filter((t) => t.status !== "done").length, | |
| done: tasks.filter((t) => t.status === "done").length, | |
| }; | |
| } | |
| export function sortTasks(tasks: Task[], key: SortKey): Task[] { | |
| const out = [...tasks]; | |
| switch (key) { | |
| case "newest": | |
| return out.sort((a, b) => b.createdAt.localeCompare(a.createdAt)); | |
| case "oldest": | |
| return out.sort((a, b) => a.createdAt.localeCompare(b.createdAt)); | |
| case "priority": | |
| return out.sort((a, b) => PRIORITY_RANK[a.priority] - PRIORITY_RANK[b.priority]); | |
| case "title": | |
| return out.sort((a, b) => a.title.localeCompare(b.title)); | |
| } | |
| } | |
| export const SORT_LABELS: Record<SortKey, string> = { | |
| newest: "Newest first", | |
| oldest: "Oldest first", | |
| priority: "Priority", | |
| title: "Title", | |
| }; | |
| export const STATUS_LABELS: Record<TaskStatus, string> = { | |
| todo: "To do", | |
| in_progress: "In progress", | |
| done: "Done", | |
| }; | |