Add comprehensive admin features and multi-system integration
- Add admin dashboard with sync controls and data browser - Implement RMM, Auvik, and Addigy organization mappings - Add chunked ticket sync with progress tracking - Implement entity sync service with rate limiting - Add analytics engine and performance optimizer - Create data browser for all PSA entities - Add navigation components and UI improvements - Implement background processing and sync services - Add comprehensive documentation and migration scripts - Update configuration items with multi-system support - Enhance contact management and purchase history - Add issue type assignment and LLM analyzer - Improve error handling and logging utilities
This commit is contained in:
parent
e8462ef301
commit
6eee14f8af
171 changed files with 32671 additions and 621 deletions
64
app/api/data/tasks/route.ts
Normal file
64
app/api/data/tasks/route.ts
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* Tasks Data API Endpoint
|
||||
* GET /api/data/tasks - Query tasks from PostgreSQL
|
||||
*/
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import postgresClient from '@/lib/services/postgres-client';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const searchParams = request.nextUrl.searchParams;
|
||||
const limit = parseInt(searchParams.get('limit') || '100');
|
||||
const offset = parseInt(searchParams.get('offset') || '0');
|
||||
const projectId = searchParams.get('projectId');
|
||||
const ticketId = searchParams.get('ticketId');
|
||||
const assignedResourceId = searchParams.get('assignedResourceId');
|
||||
const status = searchParams.get('status');
|
||||
|
||||
// Build where clause
|
||||
const where: Record<string, any> = {};
|
||||
if (projectId) {
|
||||
where.project_id = parseInt(projectId);
|
||||
}
|
||||
if (ticketId) {
|
||||
where.ticket_id = parseInt(ticketId);
|
||||
}
|
||||
if (assignedResourceId) {
|
||||
where.assigned_resource_id = parseInt(assignedResourceId);
|
||||
}
|
||||
if (status) {
|
||||
where.status = parseInt(status);
|
||||
}
|
||||
|
||||
// Query tasks
|
||||
const tasks = await postgresClient.find(
|
||||
'tasks',
|
||||
where,
|
||||
{
|
||||
limit,
|
||||
offset,
|
||||
orderBy: 'create_date_time DESC',
|
||||
}
|
||||
);
|
||||
|
||||
// Get total count
|
||||
const totalCount = await postgresClient.count('tasks', where);
|
||||
|
||||
return NextResponse.json({
|
||||
tasks,
|
||||
pagination: {
|
||||
limit,
|
||||
offset,
|
||||
total: totalCount,
|
||||
hasMore: offset + tasks.length < totalCount,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch tasks:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to fetch tasks' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue