feat(workers): Add platform badge (D/J/T) to active tasks display
- Add PlatformBadge component showing D=Dutchie, J=Jane, T=Treez - Include platform field in worker-registry API response - Fix null running_seconds displaying as "nulls" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -436,6 +436,7 @@ router.get('/workers', async (req: Request, res: Response) => {
|
|||||||
t.worker_id,
|
t.worker_id,
|
||||||
t.id as task_id,
|
t.id as task_id,
|
||||||
t.role,
|
t.role,
|
||||||
|
t.platform,
|
||||||
t.status as task_status,
|
t.status as task_status,
|
||||||
t.started_at,
|
t.started_at,
|
||||||
EXTRACT(EPOCH FROM (NOW() - t.started_at))::int as running_seconds,
|
EXTRACT(EPOCH FROM (NOW() - t.started_at))::int as running_seconds,
|
||||||
@@ -458,6 +459,7 @@ router.get('/workers', async (req: Request, res: Response) => {
|
|||||||
tasksByWorker[task.worker_id].push({
|
tasksByWorker[task.worker_id].push({
|
||||||
task_id: task.task_id,
|
task_id: task.task_id,
|
||||||
role: task.role,
|
role: task.role,
|
||||||
|
platform: task.platform,
|
||||||
status: task.task_status,
|
status: task.task_status,
|
||||||
started_at: task.started_at,
|
started_at: task.started_at,
|
||||||
running_seconds: task.running_seconds,
|
running_seconds: task.running_seconds,
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ interface ActiveTask {
|
|||||||
status: string;
|
status: string;
|
||||||
started_at: string;
|
started_at: string;
|
||||||
running_seconds: number;
|
running_seconds: number;
|
||||||
|
platform?: string;
|
||||||
dispensary?: {
|
dispensary?: {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -136,6 +137,25 @@ interface ActiveTask {
|
|||||||
} | null;
|
} | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Platform badge component
|
||||||
|
function PlatformBadge({ platform }: { platform?: string }) {
|
||||||
|
const config: Record<string, { letter: string; bg: string; text: string; title: string }> = {
|
||||||
|
dutchie: { letter: 'D', bg: 'bg-green-100', text: 'text-green-700', title: 'Dutchie' },
|
||||||
|
jane: { letter: 'J', bg: 'bg-purple-100', text: 'text-purple-700', title: 'Jane' },
|
||||||
|
treez: { letter: 'T', bg: 'bg-orange-100', text: 'text-orange-700', title: 'Treez' },
|
||||||
|
};
|
||||||
|
const p = platform?.toLowerCase() || 'dutchie';
|
||||||
|
const c = config[p] || { letter: '?', bg: 'bg-gray-100', text: 'text-gray-600', title: platform || 'Unknown' };
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={`inline-flex items-center justify-center w-4 h-4 rounded text-[10px] font-bold ${c.bg} ${c.text}`}
|
||||||
|
title={c.title}
|
||||||
|
>
|
||||||
|
{c.letter}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Current task info
|
// Current task info
|
||||||
interface Task {
|
interface Task {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -632,9 +652,9 @@ function TaskCountBadge({ worker, tasks }: { worker: Worker; tasks: Task[] }) {
|
|||||||
<div
|
<div
|
||||||
key={task.task_id}
|
key={task.task_id}
|
||||||
className="flex items-center gap-1.5 text-xs bg-blue-50 rounded px-1.5 py-0.5"
|
className="flex items-center gap-1.5 text-xs bg-blue-50 rounded px-1.5 py-0.5"
|
||||||
title={`Task #${task.task_id}: ${task.role}\n${task.dispensary?.name || 'Unknown'}\nRunning: ${formatSecondsToTime(task.running_seconds)}`}
|
title={`Task #${task.task_id}: ${task.role}\nPlatform: ${task.platform || 'dutchie'}\n${task.dispensary?.name || 'Unknown'}\nRunning: ${formatSecondsToTime(task.running_seconds)}`}
|
||||||
>
|
>
|
||||||
<div className="w-1.5 h-1.5 rounded-full bg-blue-500 animate-pulse" />
|
<PlatformBadge platform={task.platform} />
|
||||||
<span className="text-gray-600 truncate max-w-[140px]">
|
<span className="text-gray-600 truncate max-w-[140px]">
|
||||||
{task.dispensary?.name?.split(' ').slice(0, 2).join(' ') || task.role.replace(/_/g, ' ')}
|
{task.dispensary?.name?.split(' ').slice(0, 2).join(' ') || task.role.replace(/_/g, ' ')}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user