Major changes

This commit is contained in:
owenqwenstarsky
2026-01-24 16:52:19 -06:00
parent 011e40119d
commit 7181791734
46 changed files with 8371 additions and 127 deletions
+42
View File
@@ -0,0 +1,42 @@
import { prisma } from '@/lib/db';
import { NextResponse } from 'next/server';
export async function GET() {
try {
const today = new Date();
today.setHours(0, 0, 0, 0);
const [totalArticles, searchesToday, allArticles] = await Promise.all([
prisma.article.count(),
prisma.search.count({
where: {
createdAt: {
gte: today,
},
},
}),
prisma.article.findMany({
select: {
content: true,
},
}),
]);
const totalWords = allArticles.reduce((sum, article) => {
const words = article.content.split(/\s+/).filter(word => word.length > 0).length;
return sum + words;
}, 0);
return NextResponse.json({
totalArticles,
searchesToday,
totalWords,
});
} catch (error) {
console.error('Error fetching stats:', error);
return NextResponse.json(
{ error: 'Failed to fetch statistics' },
{ status: 500 }
);
}
}