45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { postgresClient } from '@/lib/services/postgres-client';
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
// Get recent ticket activity for ticker feed - exclude RMM alerts (source = 8)
|
|
const activityResult = await postgresClient.query(
|
|
`SELECT
|
|
t.ticket_number,
|
|
t.title,
|
|
t.priority,
|
|
t.status,
|
|
t.create_date,
|
|
t.last_activity_date,
|
|
c.company_name,
|
|
s.label as status_label
|
|
FROM tickets t
|
|
LEFT JOIN companies c ON t.company_id = c.id
|
|
LEFT JOIN statuses s ON t.status = s.value
|
|
WHERE t.completed_date IS NULL
|
|
AND (t.source IS NULL OR t.source != 8)
|
|
ORDER BY t.last_activity_date DESC NULLS LAST
|
|
LIMIT 50`
|
|
);
|
|
|
|
const activities = activityResult.rows.map((row: any) => ({
|
|
ticketNumber: row.ticket_number,
|
|
title: row.title,
|
|
priority: row.priority,
|
|
status: row.status,
|
|
statusLabel: row.status_label,
|
|
companyName: row.company_name,
|
|
createDate: row.create_date,
|
|
lastActivityDate: row.last_activity_date,
|
|
}));
|
|
|
|
return NextResponse.json({ activities });
|
|
} catch (error) {
|
|
console.error('Error fetching kiosk activity:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch kiosk activity' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|