🎉 first commit

This commit is contained in:
LIlGG
2025-09-24 13:06:25 +08:00
commit 1f4fb103e9
409 changed files with 61222 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import { prisma } from '~/lib/.server/prisma';
import { errorResponse, successResponse } from '~/utils/api-response';
import { createScopedLogger } from '~/utils/logger';
const logger = createScopedLogger('api.deployments.stats');
export type GetDeploymentStatsArgs = {
userId: string;
};
export async function getDeploymentStats({ userId }: GetDeploymentStatsArgs) {
try {
const totalSites = await prisma.deployment.count({
where: { userId },
});
const platformStats = await prisma.deployment.groupBy({
by: ['platform'],
_count: {
id: true,
},
where: { userId },
});
const sitesByPlatform = platformStats.reduce(
(acc, stat) => {
acc[stat.platform] = stat._count.id;
return acc;
},
{} as Record<string, number>,
);
return successResponse(
{
totalSites,
sitesByPlatform,
totalDays: 30,
},
'获取部署统计数据成功',
);
} catch (error) {
logger.error('获取部署统计数据失败:', error);
return errorResponse(500, error instanceof Error ? error.message : '获取部署统计数据失败');
}
}