@ozdao/prometheus-framework 0.1.31 → 0.1.33
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/CardOrganization-26714a5e.mjs +297 -0
- package/dist/CardOrganization-88c6d479.js +1 -0
- package/dist/Chips-0e5bdd54.js +1 -0
- package/dist/Chips-41cd6570.mjs +203 -0
- package/dist/Chips-5e32c8cb.mjs +200 -0
- package/dist/Chips-c3d7341e.js +1 -0
- package/dist/EULA-e05236af.mjs +4210 -0
- package/dist/EULA-f5fba925.js +1 -0
- package/dist/Feed-046852fc.js +1 -0
- package/dist/Feed-275a14d8.mjs +371 -0
- package/dist/Feed-4efa2a93.mjs +394 -0
- package/dist/Feed-505b3fa8.mjs +383 -0
- package/dist/Feed-acfbb839.mjs +371 -0
- package/dist/Feed-d0da2943.js +1 -0
- package/dist/Feed-e6e84388.js +1 -0
- package/dist/Feed-ee36f80b.js +1 -0
- package/dist/IconEdit-1b7b5874.js +1 -0
- package/dist/IconEdit-680dc269.mjs +339 -0
- package/dist/Image-2d2e606a.js +9 -0
- package/dist/Image-93c3a270.mjs +480 -0
- package/dist/Image-95c0fb07.mjs +480 -0
- package/dist/Image-de94b883.js +9 -0
- package/dist/Product-1892b14a.js +7 -0
- package/dist/Product-6aa1c9ee.mjs +844 -0
- package/dist/Product-6ca8d04d.js +7 -0
- package/dist/Product-d3f1d10a.mjs +844 -0
- package/dist/ProductEdit-2e309add.js +1 -0
- package/dist/ProductEdit-6abcc97b.mjs +306 -0
- package/dist/ProductEdit-8e779ed8.js +1 -0
- package/dist/ProductEdit-ebcc3f98.mjs +306 -0
- package/dist/ProfileBlogposts-62d5e809.mjs +70 -0
- package/dist/ProfileBlogposts-8c10a505.js +1 -0
- package/dist/ProfileBlogposts-a2f7cd4c.mjs +70 -0
- package/dist/ProfileBlogposts-c31917ec.js +1 -0
- package/dist/ProfileEvents-47409c9e.mjs +62 -0
- package/dist/ProfileEvents-89471c05.js +1 -0
- package/dist/ProfileEvents-db12cf78.js +1 -0
- package/dist/ProfileEvents-e070d9d4.mjs +62 -0
- package/dist/ProfileOrganizations-bee6a3ae.js +1 -0
- package/dist/ProfileOrganizations-db313b5e.mjs +219 -0
- package/dist/Publics-24f055eb.js +1 -0
- package/dist/Publics-b1cbfd97.mjs +45 -0
- package/dist/Socials-9b2d27a6.js +1 -0
- package/dist/Socials-becde7dc.mjs +275 -0
- package/dist/auth.client.cjs +7 -7
- package/dist/auth.client.js +165 -162
- package/dist/auth.server.js +4 -4
- package/dist/auth.server.mjs +4 -4
- package/dist/community.client.cjs +1 -1
- package/dist/community.client.js +218 -242
- package/dist/community.server.js +2 -2
- package/dist/community.server.mjs +2 -2
- package/dist/events.client.cjs +1 -1
- package/dist/events.client.js +5 -5
- package/dist/events.server.js +447 -262
- package/dist/events.server.mjs +447 -262
- package/dist/files.server.js +1 -1
- package/dist/files.server.mjs +1 -1
- package/dist/legal.client.cjs +1 -1
- package/dist/legal.client.js +1 -1
- package/dist/modules/community/components/sections/Feed.vue.d.ts +2 -0
- package/dist/organizations.client-6a69b54a.js +3 -0
- package/dist/organizations.client-76c3660a.mjs +3072 -0
- package/dist/organizations.client-c288ff44.mjs +3072 -0
- package/dist/organizations.client-ddbf8809.js +3 -0
- package/dist/organizations.client.cjs +1 -1
- package/dist/organizations.client.js +8 -8
- package/dist/organizations.server.js +4 -4
- package/dist/organizations.server.mjs +4 -4
- package/dist/style.css +1 -1
- package/dist/users.client.cjs +1 -1
- package/dist/users.client.js +5 -5
- package/dist/users.server.js +2 -2
- package/dist/users.server.mjs +2 -2
- package/package.json +1 -1
- package/src/components/CardHeader/CardHeader.vue +3 -3
- package/src/modules/auth/router/auth.js +1 -1
- package/src/modules/community/components/blocks/CardBlogpost.vue +2 -4
- package/src/modules/community/components/sections/Feed.vue +44 -39
- package/src/modules/community/components/sections/HotPosts.vue +9 -56
- package/src/modules/events/components/blocks/CardEvent.vue +0 -2
- package/src/modules/events/controllers/events.controller.js +55 -255
- package/src/modules/events/controllers/utils/queryProcessor.js +118 -0
- package/src/modules/events/models/event.model.js +43 -49
- package/src/modules/events/models/event.new.model.js +82 -0
- package/src/modules/files/middlewares/server/middlewareMulter.js +1 -0
- package/src/modules/globals/controllers/utils/queryProcessor.js +228 -0
- package/src/modules/globals/models/common.schema.js +14 -0
- package/src/modules/globals/models/engagement.schema.js +10 -0
- package/src/modules/globals/models/metadata.schema.js +15 -0
- package/src/modules/globals/models/ownership.schema.js +34 -0
- package/src/modules/globals/utils/seo-friendly-url.js +28 -0
- package/src/modules/legal/components/pages/legal/EULA.vue +0 -3
- package/src/modules/products/controllers/categories.controller.js +3 -0
- package/src/modules/products/models/category.model.js +63 -13
- package/src/modules/products/models/leftover.model.js +38 -17
- package/src/modules/products/models/modification.model.js +31 -14
- package/src/modules/products/models/product.model.js +37 -38
- package/src/modules/products/products.server.js +11 -1
- package/src/modules/reports/components/sections/FormReport.vue +3 -1
package/dist/events.server.mjs
CHANGED
@@ -1,234 +1,379 @@
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-83b1d755.mjs";
|
2
|
-
import require$$
|
2
|
+
import require$$0 from "mongoose";
|
3
3
|
import { s as server$1 } from "./index-fa8d5df4.mjs";
|
4
4
|
import "jsonwebtoken";
|
5
5
|
import "mongodb";
|
6
|
-
require$$
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const now = /* @__PURE__ */ new Date();
|
25
|
-
const todayStart = new Date(now.getTime());
|
26
|
-
todayStart.setHours(0, 0, 0, 0);
|
27
|
-
const todayEnd = new Date(now.getTime());
|
28
|
-
todayEnd.setHours(23, 59, 59, 999);
|
29
|
-
let dateConditions = [];
|
30
|
-
if (req.query.date) {
|
31
|
-
const dateString = req.query.date.toString();
|
32
|
-
const day = parseInt(dateString.substring(0, 2), 10);
|
33
|
-
const month = parseInt(dateString.substring(2, 4), 10) - 1;
|
34
|
-
const year = parseInt(dateString.substring(4, 8), 10);
|
35
|
-
const customDate = new Date(year, month, day);
|
36
|
-
customDate.setHours(0, 0, 0, 0);
|
37
|
-
const customDateEnd = new Date(year, month, day);
|
38
|
-
customDateEnd.setHours(23, 59, 59, 999);
|
39
|
-
dateConditions.push({ "date.start": { $gte: customDate, $lte: customDateEnd } });
|
6
|
+
const ObjectId$1 = require$$0.Types.ObjectId;
|
7
|
+
function getTicketsLookupStage() {
|
8
|
+
return {
|
9
|
+
$lookup: {
|
10
|
+
from: "tickets",
|
11
|
+
localField: "_id",
|
12
|
+
foreignField: "target",
|
13
|
+
as: "tickets",
|
14
|
+
pipeline: [{
|
15
|
+
$lookup: {
|
16
|
+
from: "users",
|
17
|
+
localField: "user",
|
18
|
+
foreignField: "_id",
|
19
|
+
as: "user"
|
20
|
+
}
|
21
|
+
}, {
|
22
|
+
$unwind: { path: "$user", preserveNullAndEmptyArrays: true }
|
23
|
+
}]
|
40
24
|
}
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
case "month":
|
53
|
-
endDate.setDate(now.getDate() + 30);
|
54
|
-
break;
|
55
|
-
case "year":
|
56
|
-
endDate.setFullYear(now.getFullYear() + 1);
|
57
|
-
break;
|
25
|
+
};
|
26
|
+
}
|
27
|
+
function getParticipantsPhotosStage() {
|
28
|
+
return {
|
29
|
+
$addFields: {
|
30
|
+
participantsPhotos: {
|
31
|
+
$map: {
|
32
|
+
input: "$tickets",
|
33
|
+
as: "ticket",
|
34
|
+
in: "$$ticket.user.profile.photo"
|
35
|
+
}
|
58
36
|
}
|
59
|
-
dateConditions.push({ "date.start": { $gte: startDate, $lte: endDate } });
|
60
37
|
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
38
|
+
};
|
39
|
+
}
|
40
|
+
function getNumberOfTicketsStage() {
|
41
|
+
return {
|
42
|
+
$addFields: {
|
43
|
+
numberOfTickets: { $size: "$tickets" }
|
66
44
|
}
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
case "live":
|
77
|
-
dateConditions.push({ "date.start": { $lte: now } });
|
78
|
-
dateConditions.push({ "date.end": { $gte: now } });
|
79
|
-
break;
|
80
|
-
case "planned":
|
81
|
-
dateConditions.push({ "date.start": { $gt: now } });
|
82
|
-
break;
|
45
|
+
};
|
46
|
+
}
|
47
|
+
function getHasTicketStage(user) {
|
48
|
+
if (user) {
|
49
|
+
return [{
|
50
|
+
$addFields: {
|
51
|
+
hasTicket: {
|
52
|
+
$in: [new ObjectId$1(user), "$tickets.user._id"]
|
53
|
+
}
|
83
54
|
}
|
55
|
+
}];
|
56
|
+
} else {
|
57
|
+
return [];
|
58
|
+
}
|
59
|
+
}
|
60
|
+
function getProjectStage() {
|
61
|
+
return {
|
62
|
+
$project: {
|
63
|
+
_id: 1,
|
64
|
+
url: 1,
|
65
|
+
cover: 1,
|
66
|
+
name: 1,
|
67
|
+
status: 1,
|
68
|
+
description: 1,
|
69
|
+
content: 1,
|
70
|
+
owner: 1,
|
71
|
+
creator: 1,
|
72
|
+
tags: 1,
|
73
|
+
date: 1,
|
74
|
+
numberOfTickets: 1,
|
75
|
+
participantsPhotos: 1,
|
76
|
+
hasTicket: 1,
|
77
|
+
tickets: 1,
|
78
|
+
createdAt: 1
|
84
79
|
}
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
foreignField: "_id",
|
99
|
-
as: "user"
|
100
|
-
}
|
101
|
-
}, {
|
102
|
-
$unwind: { path: "$user", preserveNullAndEmptyArrays: true }
|
103
|
-
}]
|
104
|
-
}
|
105
|
-
},
|
106
|
-
{
|
107
|
-
$addFields: {
|
108
|
-
participantsPhotos: {
|
109
|
-
$map: {
|
110
|
-
input: "$tickets",
|
111
|
-
as: "ticket",
|
112
|
-
in: "$$ticket.user.profile.photo"
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
116
|
-
},
|
117
|
-
{
|
118
|
-
$addFields: {
|
119
|
-
numberOfTickets: { $size: "$tickets" }
|
120
|
-
}
|
121
|
-
},
|
122
|
-
{
|
123
|
-
$addFields: {
|
124
|
-
hasTicket: {
|
125
|
-
$cond: {
|
126
|
-
if: req.query.user,
|
127
|
-
then: {
|
128
|
-
$in: [new db.mongoose.Types.ObjectId(req.query.user), "$tickets.user._id"]
|
129
|
-
},
|
130
|
-
else: "$$REMOVE"
|
131
|
-
}
|
80
|
+
};
|
81
|
+
}
|
82
|
+
function getParticipantStages(participantQuery) {
|
83
|
+
const participantId = participantQuery ? new ObjectId$1(participantQuery) : null;
|
84
|
+
let stages = [];
|
85
|
+
if (participantId) {
|
86
|
+
stages.push({
|
87
|
+
$addFields: {
|
88
|
+
"participantTickets": {
|
89
|
+
$filter: {
|
90
|
+
input: "$tickets",
|
91
|
+
as: "ticket",
|
92
|
+
cond: { $eq: ["$$ticket.user._id", participantId] }
|
132
93
|
}
|
133
94
|
}
|
134
|
-
}
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
95
|
+
}
|
96
|
+
});
|
97
|
+
stages.push({
|
98
|
+
$match: {
|
99
|
+
"participantTickets.0": { $exists: true }
|
100
|
+
}
|
101
|
+
});
|
102
|
+
}
|
103
|
+
return stages;
|
104
|
+
}
|
105
|
+
var queryProcessor$2 = {
|
106
|
+
getTicketsLookupStage,
|
107
|
+
getParticipantsPhotosStage,
|
108
|
+
getNumberOfTicketsStage,
|
109
|
+
getHasTicketStage,
|
110
|
+
getProjectStage,
|
111
|
+
getParticipantStages
|
112
|
+
};
|
113
|
+
const ObjectId = require$$0.Types.ObjectId;
|
114
|
+
function getBasicOptions(query) {
|
115
|
+
const { _id, url, owner, creator } = query;
|
116
|
+
const conditions = [];
|
117
|
+
if (_id) {
|
118
|
+
conditions.push({ _id: new ObjectId(_id) });
|
119
|
+
}
|
120
|
+
if (url) {
|
121
|
+
conditions.push({ url });
|
122
|
+
}
|
123
|
+
if (owner) {
|
124
|
+
conditions.push({ "owner.target": new ObjectId(owner) });
|
125
|
+
}
|
126
|
+
if (creator) {
|
127
|
+
conditions.push({ "creator.target": new ObjectId(creator) });
|
128
|
+
}
|
129
|
+
if (conditions.length > 0) {
|
130
|
+
return [{ $match: { $and: conditions } }];
|
131
|
+
} else {
|
132
|
+
return [];
|
133
|
+
}
|
134
|
+
}
|
135
|
+
function getSortingOptions(query) {
|
136
|
+
const sortParam = query.sortParam || "date.start";
|
137
|
+
const sortOrder = query.sortOrder || "desc";
|
138
|
+
let sort = {
|
139
|
+
[sortParam]: sortOrder === "desc" ? -1 : 1,
|
140
|
+
"_id": 1
|
141
|
+
};
|
142
|
+
return [{ $sort: sort }];
|
143
|
+
}
|
144
|
+
function getPaginationOptions(query) {
|
145
|
+
let pagination = {
|
146
|
+
skip: parseInt(query.skip) || 0,
|
147
|
+
limit: parseInt(query.limit) || 20
|
148
|
+
};
|
149
|
+
return [{ $skip: pagination.skip }, { $limit: pagination.limit }];
|
150
|
+
}
|
151
|
+
function getDateConditions(date) {
|
152
|
+
if (date) {
|
153
|
+
const dateString = date.toString();
|
154
|
+
const day = parseInt(dateString.substring(0, 2), 10);
|
155
|
+
const month = parseInt(dateString.substring(2, 4), 10) - 1;
|
156
|
+
const year = parseInt(dateString.substring(4, 8), 10);
|
157
|
+
const customDate = new Date(year, month, day);
|
158
|
+
customDate.setHours(0, 0, 0, 0);
|
159
|
+
const customDateEnd = new Date(year, month, day);
|
160
|
+
customDateEnd.setHours(23, 59, 59, 999);
|
161
|
+
return [{ $match: { "date.start": { $gte: customDate, $lte: customDateEnd } } }];
|
162
|
+
} else {
|
163
|
+
return [];
|
164
|
+
}
|
165
|
+
}
|
166
|
+
function getPeriodConditions(period, periodStart, periodEnd) {
|
167
|
+
const now = /* @__PURE__ */ new Date();
|
168
|
+
let startDate, endDate;
|
169
|
+
if (periodStart && periodEnd) {
|
170
|
+
startDate = new Date(periodStart);
|
171
|
+
endDate = new Date(periodEnd);
|
172
|
+
return [{
|
173
|
+
$match: {
|
174
|
+
"date.start": {
|
175
|
+
$gte: startDate,
|
176
|
+
$lte: endDate
|
166
177
|
}
|
167
|
-
}
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
178
|
+
}
|
179
|
+
}];
|
180
|
+
} else if (period) {
|
181
|
+
startDate = new Date(now.getTime());
|
182
|
+
endDate = new Date(now.getTime());
|
183
|
+
switch (period) {
|
184
|
+
case "today":
|
185
|
+
startDate.setHours(0, 0, 0, 0);
|
186
|
+
endDate.setHours(23, 59, 59, 999);
|
187
|
+
break;
|
188
|
+
case "week":
|
189
|
+
endDate.setDate(now.getDate() + 7);
|
190
|
+
break;
|
191
|
+
case "month":
|
192
|
+
endDate.setDate(now.getDate() + 30);
|
193
|
+
break;
|
194
|
+
case "year":
|
195
|
+
endDate.setFullYear(now.getFullYear() + 1);
|
196
|
+
break;
|
197
|
+
}
|
198
|
+
return [{
|
199
|
+
$match: {
|
200
|
+
"date.start": {
|
201
|
+
$gte: startDate,
|
202
|
+
$lte: endDate
|
184
203
|
}
|
204
|
+
}
|
205
|
+
}];
|
206
|
+
} else {
|
207
|
+
return [];
|
208
|
+
}
|
209
|
+
}
|
210
|
+
function getStatusConditions(status) {
|
211
|
+
const now = /* @__PURE__ */ new Date();
|
212
|
+
const todayStart = new Date(now.getTime());
|
213
|
+
todayStart.setHours(0, 0, 0, 0);
|
214
|
+
const todayEnd = new Date(now.getTime());
|
215
|
+
todayEnd.setHours(23, 59, 59, 999);
|
216
|
+
let matchConditions = [];
|
217
|
+
switch (status) {
|
218
|
+
case "finished":
|
219
|
+
matchConditions.push({ "date.start": { $lt: now } });
|
220
|
+
break;
|
221
|
+
case "today":
|
222
|
+
matchConditions.push({ "date.start": { $gte: todayStart, $lte: todayEnd } });
|
223
|
+
break;
|
224
|
+
case "live":
|
225
|
+
matchConditions.push({ "date.start": { $lte: now } });
|
226
|
+
matchConditions.push({ "date.end": { $gte: now } });
|
227
|
+
break;
|
228
|
+
case "planned":
|
229
|
+
matchConditions.push({ "date.start": { $gt: now } });
|
230
|
+
break;
|
231
|
+
}
|
232
|
+
if (matchConditions && matchConditions.length > 0) {
|
233
|
+
return [{ $match: { $and: matchConditions } }];
|
234
|
+
} else {
|
235
|
+
return [];
|
236
|
+
}
|
237
|
+
}
|
238
|
+
function getCreatorUserLookupStage() {
|
239
|
+
return {
|
240
|
+
$lookup: {
|
241
|
+
from: "users",
|
242
|
+
localField: "creator.target",
|
243
|
+
foreignField: "_id",
|
244
|
+
as: "creatorUser"
|
245
|
+
}
|
246
|
+
};
|
247
|
+
}
|
248
|
+
function getCreatorOrganizationLookupStage() {
|
249
|
+
return {
|
250
|
+
$lookup: {
|
251
|
+
from: "organizations",
|
252
|
+
localField: "creator.target",
|
253
|
+
foreignField: "_id",
|
254
|
+
as: "creatorOrganization"
|
255
|
+
}
|
256
|
+
};
|
257
|
+
}
|
258
|
+
function getOwnerUserLookupStage() {
|
259
|
+
return {
|
260
|
+
$lookup: {
|
261
|
+
from: "users",
|
262
|
+
localField: "owner.target",
|
263
|
+
foreignField: "_id",
|
264
|
+
as: "ownerUser"
|
265
|
+
}
|
266
|
+
};
|
267
|
+
}
|
268
|
+
function getOwnerOrganizationLookupStage() {
|
269
|
+
return {
|
270
|
+
$lookup: {
|
271
|
+
from: "organizations",
|
272
|
+
localField: "owner.target",
|
273
|
+
foreignField: "_id",
|
274
|
+
as: "ownerOrganization"
|
275
|
+
}
|
276
|
+
};
|
277
|
+
}
|
278
|
+
function getAddFieldsCreatorOwnerStage() {
|
279
|
+
return {
|
280
|
+
$addFields: {
|
281
|
+
"creator.target": {
|
282
|
+
$cond: [
|
283
|
+
{ $eq: ["$creator.type", "user"] },
|
284
|
+
{ $arrayElemAt: ["$creatorUser", 0] },
|
285
|
+
{ $arrayElemAt: ["$creatorOrganization", 0] }
|
286
|
+
]
|
185
287
|
},
|
186
|
-
{
|
187
|
-
$
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
status: 1,
|
193
|
-
description: 1,
|
194
|
-
content: 1,
|
195
|
-
owner: 1,
|
196
|
-
creator: 1,
|
197
|
-
tags: 1,
|
198
|
-
date: 1,
|
199
|
-
numberOfTickets: 1,
|
200
|
-
participantsPhotos: 1,
|
201
|
-
hasTicket: 1,
|
202
|
-
tickets: 1,
|
203
|
-
createdAt: 1
|
204
|
-
}
|
288
|
+
"owner.target": {
|
289
|
+
$cond: [
|
290
|
+
{ $eq: ["$owner.type", "user"] },
|
291
|
+
{ $arrayElemAt: ["$ownerUser", 0] },
|
292
|
+
{ $arrayElemAt: ["$ownerOrganization", 0] }
|
293
|
+
]
|
205
294
|
}
|
206
|
-
];
|
207
|
-
const participantId = req.query.participant ? new db.mongoose.Types.ObjectId(req.query.participant) : null;
|
208
|
-
if (participantId) {
|
209
|
-
stages.push({
|
210
|
-
$addFields: {
|
211
|
-
"participantTickets": {
|
212
|
-
$filter: {
|
213
|
-
input: "$tickets",
|
214
|
-
as: "ticket",
|
215
|
-
cond: { $eq: ["$$ticket.user._id", participantId] }
|
216
|
-
}
|
217
|
-
}
|
218
|
-
}
|
219
|
-
});
|
220
|
-
stages.push({
|
221
|
-
$match: {
|
222
|
-
"participantTickets.0": { $exists: true }
|
223
|
-
}
|
224
|
-
});
|
225
295
|
}
|
226
|
-
|
227
|
-
|
228
|
-
|
296
|
+
};
|
297
|
+
}
|
298
|
+
var queryProcessor$1 = {
|
299
|
+
getBasicOptions,
|
300
|
+
getSortingOptions,
|
301
|
+
getPaginationOptions,
|
302
|
+
getDateConditions,
|
303
|
+
getStatusConditions,
|
304
|
+
getPeriodConditions,
|
305
|
+
// Creator and Owner
|
306
|
+
getCreatorUserLookupStage,
|
307
|
+
getCreatorOrganizationLookupStage,
|
308
|
+
getOwnerUserLookupStage,
|
309
|
+
getOwnerOrganizationLookupStage,
|
310
|
+
getAddFieldsCreatorOwnerStage
|
311
|
+
};
|
312
|
+
function createFriendlyURL$1(str) {
|
313
|
+
if (typeof str !== "string") {
|
314
|
+
throw new Error("Входные данные должны быть строкой");
|
315
|
+
}
|
316
|
+
str = str.trim().toLowerCase();
|
317
|
+
str = str.replace(/ /g, "-").replace(/[^\w-]+/g, "");
|
318
|
+
str = str.replace(/-+/g, "-");
|
319
|
+
str = str.replace(/^-+|-+$/g, "");
|
320
|
+
return str;
|
321
|
+
}
|
322
|
+
var seoFriendlyUrl = createFriendlyURL$1;
|
323
|
+
require$$0.Types.ObjectId;
|
324
|
+
const queryProcessor = queryProcessor$2;
|
325
|
+
const queryProcessorGlobals = queryProcessor$1;
|
326
|
+
const createFriendlyURL = seoFriendlyUrl;
|
327
|
+
const middlewareFactory = (db) => {
|
328
|
+
db.ticket;
|
329
|
+
const Event = db.event;
|
330
|
+
db.membership;
|
331
|
+
const read = async (req, res) => {
|
332
|
+
let stages = [];
|
333
|
+
stages = [
|
334
|
+
...queryProcessorGlobals.getBasicOptions(
|
335
|
+
req.query
|
336
|
+
),
|
337
|
+
...queryProcessorGlobals.getDateConditions(
|
338
|
+
req.query.date
|
339
|
+
),
|
340
|
+
...queryProcessorGlobals.getPeriodConditions(
|
341
|
+
req.query.period,
|
342
|
+
req.query.periodStart,
|
343
|
+
req.query.periodEnd
|
344
|
+
),
|
345
|
+
...queryProcessorGlobals.getStatusConditions(
|
346
|
+
req.query.status
|
347
|
+
),
|
348
|
+
// Tickets and Participants
|
349
|
+
queryProcessor.getTicketsLookupStage(),
|
350
|
+
queryProcessor.getParticipantsPhotosStage(),
|
351
|
+
queryProcessor.getNumberOfTicketsStage(),
|
352
|
+
...queryProcessor.getHasTicketStage(
|
353
|
+
req.query.user
|
354
|
+
),
|
355
|
+
...queryProcessor.getParticipantStages(
|
356
|
+
req.query.participant
|
357
|
+
),
|
358
|
+
// For creator
|
359
|
+
queryProcessorGlobals.getCreatorUserLookupStage(),
|
360
|
+
queryProcessorGlobals.getCreatorOrganizationLookupStage(),
|
361
|
+
// For owner
|
362
|
+
queryProcessorGlobals.getOwnerUserLookupStage(),
|
363
|
+
queryProcessorGlobals.getOwnerOrganizationLookupStage(),
|
364
|
+
queryProcessorGlobals.getAddFieldsCreatorOwnerStage(),
|
365
|
+
// Get object
|
366
|
+
queryProcessor.getProjectStage(),
|
367
|
+
// Pagination
|
368
|
+
...queryProcessorGlobals.getSortingOptions(
|
369
|
+
req.query
|
370
|
+
),
|
371
|
+
...queryProcessorGlobals.getPaginationOptions(
|
372
|
+
req.query
|
373
|
+
)
|
374
|
+
];
|
229
375
|
try {
|
230
|
-
const events = await Event.aggregate(stages);
|
231
|
-
console.log(events);
|
376
|
+
const events = await Event.aggregate(stages).exec();
|
232
377
|
res.status(200).send(events);
|
233
378
|
} catch (err) {
|
234
379
|
console.log(err);
|
@@ -236,16 +381,16 @@ const middlewareFactory = (db) => {
|
|
236
381
|
}
|
237
382
|
};
|
238
383
|
const create = async (req, res) => {
|
239
|
-
|
384
|
+
if (req.body._id)
|
240
385
|
delete req.body._id;
|
241
|
-
|
386
|
+
try {
|
387
|
+
req.body.url = createFriendlyURL(req.body.name);
|
242
388
|
const event = await Event.create(req.body);
|
243
389
|
if (!event) {
|
244
390
|
return res.status(404).send({ message: "Event is not created." });
|
245
391
|
}
|
246
392
|
res.status(200).send(event);
|
247
393
|
} catch (err) {
|
248
|
-
console.log(err);
|
249
394
|
return res.status(500).send({ message: err.message });
|
250
395
|
}
|
251
396
|
};
|
@@ -487,44 +632,28 @@ var tickets_routes = function(app, db, origins) {
|
|
487
632
|
);
|
488
633
|
};
|
489
634
|
const tickets_routes$1 = /* @__PURE__ */ getDefaultExportFromCjs(tickets_routes);
|
490
|
-
var
|
491
|
-
const
|
492
|
-
url: {
|
493
|
-
type: String,
|
494
|
-
required: true
|
495
|
-
},
|
496
|
-
cover: {
|
497
|
-
type: String
|
498
|
-
},
|
499
|
-
name: {
|
500
|
-
type: String,
|
501
|
-
required: true
|
502
|
-
},
|
635
|
+
var common_schema = (mongoose) => {
|
636
|
+
const CommonSchema2 = new mongoose.Schema({
|
503
637
|
status: {
|
504
638
|
type: String,
|
505
639
|
enum: ["draft", "published", "removed"],
|
506
640
|
default: "draft",
|
507
641
|
required: true
|
508
|
-
}
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
}
|
524
|
-
},
|
525
|
-
tags: [{
|
526
|
-
type: String
|
527
|
-
}],
|
642
|
+
}
|
643
|
+
});
|
644
|
+
return CommonSchema2;
|
645
|
+
};
|
646
|
+
var engagement_schema = (db) => {
|
647
|
+
const EngagementSchema2 = new db.mongoose.Schema({
|
648
|
+
views: {
|
649
|
+
type: Number,
|
650
|
+
default: 0
|
651
|
+
}
|
652
|
+
});
|
653
|
+
return EngagementSchema2;
|
654
|
+
};
|
655
|
+
var ownership_schema = (mongoose) => {
|
656
|
+
const OwnershipSchema2 = new mongoose.Schema({
|
528
657
|
owner: {
|
529
658
|
type: {
|
530
659
|
type: String,
|
@@ -532,12 +661,7 @@ var event_model = (mongoose) => {
|
|
532
661
|
},
|
533
662
|
target: {
|
534
663
|
type: mongoose.Schema.Types.ObjectId,
|
535
|
-
|
536
|
-
if (this.owner.type === "user")
|
537
|
-
return "User";
|
538
|
-
if (this.owner.type === "organization")
|
539
|
-
return "Organization";
|
540
|
-
},
|
664
|
+
refPath: "owner.type",
|
541
665
|
required: true
|
542
666
|
}
|
543
667
|
},
|
@@ -552,13 +676,60 @@ var event_model = (mongoose) => {
|
|
552
676
|
},
|
553
677
|
target: {
|
554
678
|
type: mongoose.Schema.Types.ObjectId,
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
679
|
+
refPath: "creator.type",
|
680
|
+
required: true
|
681
|
+
}
|
682
|
+
}
|
683
|
+
});
|
684
|
+
return OwnershipSchema2;
|
685
|
+
};
|
686
|
+
var metadata_schema = (mongoose) => {
|
687
|
+
const MetadataSchema2 = new mongoose.Schema({
|
688
|
+
url: {
|
689
|
+
type: String,
|
690
|
+
required: true
|
691
|
+
},
|
692
|
+
tags: [{
|
693
|
+
type: String
|
694
|
+
}]
|
695
|
+
});
|
696
|
+
return MetadataSchema2;
|
697
|
+
};
|
698
|
+
const CommonSchema = common_schema;
|
699
|
+
const EngagementSchema = engagement_schema;
|
700
|
+
const OwnershipSchema = ownership_schema;
|
701
|
+
const MetadataSchema = metadata_schema;
|
702
|
+
var event_model = (db) => {
|
703
|
+
const EventSchema = new db.mongoose.Schema({
|
704
|
+
...CommonSchema,
|
705
|
+
...EngagementSchema,
|
706
|
+
...OwnershipSchema,
|
707
|
+
...MetadataSchema,
|
708
|
+
// views: {
|
709
|
+
// type: Number,
|
710
|
+
// default: 0
|
711
|
+
// },
|
712
|
+
cover: {
|
713
|
+
type: String
|
714
|
+
},
|
715
|
+
name: {
|
716
|
+
type: String,
|
717
|
+
required: true
|
718
|
+
},
|
719
|
+
description: {
|
720
|
+
type: String,
|
721
|
+
required: true
|
722
|
+
},
|
723
|
+
content: {
|
724
|
+
type: Array
|
725
|
+
},
|
726
|
+
date: {
|
727
|
+
start: {
|
728
|
+
type: Date,
|
561
729
|
required: true
|
730
|
+
},
|
731
|
+
end: {
|
732
|
+
type: Date
|
562
733
|
}
|
563
734
|
}
|
564
735
|
}, {
|
@@ -567,7 +738,21 @@ var event_model = (mongoose) => {
|
|
567
738
|
}
|
568
739
|
});
|
569
740
|
EventSchema.index({ "url": 1, "name": 1, "date.start": 1, "date.end": -1, "tags": 1, "owner.target": 1, "creator.target": 1 });
|
570
|
-
|
741
|
+
EventSchema.post("aggregate", async function(docs) {
|
742
|
+
console.log(EventSchema);
|
743
|
+
if (docs.length > 0) {
|
744
|
+
console.log("Post-aggregate hook triggered");
|
745
|
+
try {
|
746
|
+
await Promise.all(docs.map(async (doc) => {
|
747
|
+
console.log(doc._id);
|
748
|
+
const updatedViews = await db.event.findOneAndUpdate({ _id: doc._id }, { $inc: { views: 1 } }).exec();
|
749
|
+
}));
|
750
|
+
} catch (error) {
|
751
|
+
console.error("Error updating views:", error);
|
752
|
+
}
|
753
|
+
}
|
754
|
+
});
|
755
|
+
const Event = db.mongoose.model("Event", EventSchema);
|
571
756
|
return Event;
|
572
757
|
};
|
573
758
|
const event_model$1 = /* @__PURE__ */ getDefaultExportFromCjs(event_model);
|