fix admin panel + payment ok page

This commit is contained in:
Emily
2025-04-28 18:52:38 +02:00
parent b709ad285a
commit 1917b74c32
20 changed files with 332 additions and 142 deletions

View File

@@ -1,8 +1,11 @@
import { ProjectModel, TProject } from "@schema/project/ProjectSchema";
import { TProjectLimit } from "~/shared/schema/project/ProjectsLimits";
import { TPremium } from "~/shared/schema/PremiumSchema";
import { TUser } from "~/shared/schema/UserSchema";
type ExtendedProject = {
limits: TProjectLimit[],
user: [TUser],
premium: [TPremium],
counts: [{
events: number,
visits: number,
@@ -54,14 +57,14 @@ export default defineEventHandler(async event => {
const count = await ProjectModel.countDocuments(matchQuery);
const projects = await ProjectModel.aggregate([
{
{
$match: matchQuery
},
},
{
$lookup: {
from: "project_limits",
localField: "_id",
foreignField: "project_id",
from: "user_limits",
localField: "owner",
foreignField: "user_id",
as: "limits"
}
},
@@ -73,6 +76,22 @@ export default defineEventHandler(async event => {
as: "counts"
}
},
{
$lookup: {
from: "users",
localField: "owner",
foreignField: "_id",
as: "user"
}
},
{
$lookup: {
from: "premiums",
localField: "owner",
foreignField: "user_id",
as: "premium"
}
},
{
$addFields: addFieldsFromArray([
{ arrayName: 'counts', fieldName: 'visits', projectedName: 'visits' },