Update various configuration files, components, and assets; enhance notification system and API endpoints; improve documentation and styles across the application.
This commit is contained in:
52
server/api/notifications/queue/stats.get.js
Normal file
52
server/api/notifications/queue/stats.get.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import prisma from "~/server/utils/prisma";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
// Get current date and set to start of day
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
// Count pending jobs
|
||||
const pending = await prisma.notification_queue.count({
|
||||
where: {
|
||||
status: "queued",
|
||||
},
|
||||
});
|
||||
|
||||
// Count completed jobs today
|
||||
const completed = await prisma.notification_queue.count({
|
||||
where: {
|
||||
status: "completed",
|
||||
updated_at: {
|
||||
gte: today,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Count failed jobs
|
||||
const failed = await prisma.notification_queue.count({
|
||||
where: {
|
||||
status: "failed",
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
pending,
|
||||
completed,
|
||||
failed,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching queue stats:", error);
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: "Failed to fetch queue statistics",
|
||||
data: {
|
||||
error: error.message,
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user