@ozdao/prometheus-framework 0.1.33 → 0.1.34
Sign up to get free protection for your applications and to get access to all the features.
package/dist/events.server.js
CHANGED
@@ -634,28 +634,44 @@ var tickets_routes = function(app, db, origins) {
|
|
634
634
|
);
|
635
635
|
};
|
636
636
|
const tickets_routes$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(tickets_routes);
|
637
|
-
var
|
638
|
-
const
|
637
|
+
var event_model = (mongoose) => {
|
638
|
+
const EventSchema = new mongoose.Schema({
|
639
|
+
url: {
|
640
|
+
type: String,
|
641
|
+
required: true
|
642
|
+
},
|
643
|
+
cover: {
|
644
|
+
type: String
|
645
|
+
},
|
646
|
+
name: {
|
647
|
+
type: String,
|
648
|
+
required: true
|
649
|
+
},
|
639
650
|
status: {
|
640
651
|
type: String,
|
641
652
|
enum: ["draft", "published", "removed"],
|
642
653
|
default: "draft",
|
643
654
|
required: true
|
644
|
-
}
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
}
|
657
|
-
|
658
|
-
|
655
|
+
},
|
656
|
+
description: {
|
657
|
+
type: String,
|
658
|
+
required: true
|
659
|
+
},
|
660
|
+
content: {
|
661
|
+
type: Array
|
662
|
+
},
|
663
|
+
date: {
|
664
|
+
start: {
|
665
|
+
type: Date,
|
666
|
+
required: true
|
667
|
+
},
|
668
|
+
end: {
|
669
|
+
type: Date
|
670
|
+
}
|
671
|
+
},
|
672
|
+
tags: [{
|
673
|
+
type: String
|
674
|
+
}],
|
659
675
|
owner: {
|
660
676
|
type: {
|
661
677
|
type: String,
|
@@ -663,7 +679,12 @@ var ownership_schema = (mongoose) => {
|
|
663
679
|
},
|
664
680
|
target: {
|
665
681
|
type: mongoose.Schema.Types.ObjectId,
|
666
|
-
|
682
|
+
ref: function(value) {
|
683
|
+
if (this.owner.type === "user")
|
684
|
+
return "User";
|
685
|
+
if (this.owner.type === "organization")
|
686
|
+
return "Organization";
|
687
|
+
},
|
667
688
|
required: true
|
668
689
|
}
|
669
690
|
},
|
@@ -678,83 +699,22 @@ var ownership_schema = (mongoose) => {
|
|
678
699
|
},
|
679
700
|
target: {
|
680
701
|
type: mongoose.Schema.Types.ObjectId,
|
681
|
-
|
702
|
+
ref: function(value) {
|
703
|
+
if (this.owner.type === "user")
|
704
|
+
return "User";
|
705
|
+
if (this.owner.type === "organization")
|
706
|
+
return "Organization";
|
707
|
+
},
|
682
708
|
required: true
|
683
709
|
}
|
684
710
|
}
|
685
|
-
});
|
686
|
-
return OwnershipSchema2;
|
687
|
-
};
|
688
|
-
var metadata_schema = (mongoose) => {
|
689
|
-
const MetadataSchema2 = new mongoose.Schema({
|
690
|
-
url: {
|
691
|
-
type: String,
|
692
|
-
required: true
|
693
|
-
},
|
694
|
-
tags: [{
|
695
|
-
type: String
|
696
|
-
}]
|
697
|
-
});
|
698
|
-
return MetadataSchema2;
|
699
|
-
};
|
700
|
-
const CommonSchema = common_schema;
|
701
|
-
const EngagementSchema = engagement_schema;
|
702
|
-
const OwnershipSchema = ownership_schema;
|
703
|
-
const MetadataSchema = metadata_schema;
|
704
|
-
var event_model = (db) => {
|
705
|
-
const EventSchema = new db.mongoose.Schema({
|
706
|
-
...CommonSchema,
|
707
|
-
...EngagementSchema,
|
708
|
-
...OwnershipSchema,
|
709
|
-
...MetadataSchema,
|
710
|
-
// views: {
|
711
|
-
// type: Number,
|
712
|
-
// default: 0
|
713
|
-
// },
|
714
|
-
cover: {
|
715
|
-
type: String
|
716
|
-
},
|
717
|
-
name: {
|
718
|
-
type: String,
|
719
|
-
required: true
|
720
|
-
},
|
721
|
-
description: {
|
722
|
-
type: String,
|
723
|
-
required: true
|
724
|
-
},
|
725
|
-
content: {
|
726
|
-
type: Array
|
727
|
-
},
|
728
|
-
date: {
|
729
|
-
start: {
|
730
|
-
type: Date,
|
731
|
-
required: true
|
732
|
-
},
|
733
|
-
end: {
|
734
|
-
type: Date
|
735
|
-
}
|
736
|
-
}
|
737
711
|
}, {
|
738
712
|
timestamps: {
|
739
713
|
currentTime: () => Date.now()
|
740
714
|
}
|
741
715
|
});
|
742
716
|
EventSchema.index({ "url": 1, "name": 1, "date.start": 1, "date.end": -1, "tags": 1, "owner.target": 1, "creator.target": 1 });
|
743
|
-
|
744
|
-
console.log(EventSchema);
|
745
|
-
if (docs.length > 0) {
|
746
|
-
console.log("Post-aggregate hook triggered");
|
747
|
-
try {
|
748
|
-
await Promise.all(docs.map(async (doc) => {
|
749
|
-
console.log(doc._id);
|
750
|
-
const updatedViews = await db.event.findOneAndUpdate({ _id: doc._id }, { $inc: { views: 1 } }).exec();
|
751
|
-
}));
|
752
|
-
} catch (error) {
|
753
|
-
console.error("Error updating views:", error);
|
754
|
-
}
|
755
|
-
}
|
756
|
-
});
|
757
|
-
const Event = db.mongoose.model("Event", EventSchema);
|
717
|
+
const Event = mongoose.model("Event", EventSchema);
|
758
718
|
return Event;
|
759
719
|
};
|
760
720
|
const event_model$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(event_model);
|
package/dist/events.server.mjs
CHANGED
@@ -632,28 +632,44 @@ var tickets_routes = function(app, db, origins) {
|
|
632
632
|
);
|
633
633
|
};
|
634
634
|
const tickets_routes$1 = /* @__PURE__ */ getDefaultExportFromCjs(tickets_routes);
|
635
|
-
var
|
636
|
-
const
|
635
|
+
var event_model = (mongoose) => {
|
636
|
+
const EventSchema = new mongoose.Schema({
|
637
|
+
url: {
|
638
|
+
type: String,
|
639
|
+
required: true
|
640
|
+
},
|
641
|
+
cover: {
|
642
|
+
type: String
|
643
|
+
},
|
644
|
+
name: {
|
645
|
+
type: String,
|
646
|
+
required: true
|
647
|
+
},
|
637
648
|
status: {
|
638
649
|
type: String,
|
639
650
|
enum: ["draft", "published", "removed"],
|
640
651
|
default: "draft",
|
641
652
|
required: true
|
642
|
-
}
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
}
|
655
|
-
|
656
|
-
|
653
|
+
},
|
654
|
+
description: {
|
655
|
+
type: String,
|
656
|
+
required: true
|
657
|
+
},
|
658
|
+
content: {
|
659
|
+
type: Array
|
660
|
+
},
|
661
|
+
date: {
|
662
|
+
start: {
|
663
|
+
type: Date,
|
664
|
+
required: true
|
665
|
+
},
|
666
|
+
end: {
|
667
|
+
type: Date
|
668
|
+
}
|
669
|
+
},
|
670
|
+
tags: [{
|
671
|
+
type: String
|
672
|
+
}],
|
657
673
|
owner: {
|
658
674
|
type: {
|
659
675
|
type: String,
|
@@ -661,7 +677,12 @@ var ownership_schema = (mongoose) => {
|
|
661
677
|
},
|
662
678
|
target: {
|
663
679
|
type: mongoose.Schema.Types.ObjectId,
|
664
|
-
|
680
|
+
ref: function(value) {
|
681
|
+
if (this.owner.type === "user")
|
682
|
+
return "User";
|
683
|
+
if (this.owner.type === "organization")
|
684
|
+
return "Organization";
|
685
|
+
},
|
665
686
|
required: true
|
666
687
|
}
|
667
688
|
},
|
@@ -676,83 +697,22 @@ var ownership_schema = (mongoose) => {
|
|
676
697
|
},
|
677
698
|
target: {
|
678
699
|
type: mongoose.Schema.Types.ObjectId,
|
679
|
-
|
700
|
+
ref: function(value) {
|
701
|
+
if (this.owner.type === "user")
|
702
|
+
return "User";
|
703
|
+
if (this.owner.type === "organization")
|
704
|
+
return "Organization";
|
705
|
+
},
|
680
706
|
required: true
|
681
707
|
}
|
682
708
|
}
|
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,
|
729
|
-
required: true
|
730
|
-
},
|
731
|
-
end: {
|
732
|
-
type: Date
|
733
|
-
}
|
734
|
-
}
|
735
709
|
}, {
|
736
710
|
timestamps: {
|
737
711
|
currentTime: () => Date.now()
|
738
712
|
}
|
739
713
|
});
|
740
714
|
EventSchema.index({ "url": 1, "name": 1, "date.start": 1, "date.end": -1, "tags": 1, "owner.target": 1, "creator.target": 1 });
|
741
|
-
|
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);
|
715
|
+
const Event = mongoose.model("Event", EventSchema);
|
756
716
|
return Event;
|
757
717
|
};
|
758
718
|
const event_model$1 = /* @__PURE__ */ getDefaultExportFromCjs(event_model);
|
package/package.json
CHANGED
@@ -1,19 +1,9 @@
|
|
1
|
-
|
2
|
-
const
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
const EventSchema = new db.mongoose.Schema({
|
9
|
-
...CommonSchema,
|
10
|
-
...EngagementSchema,
|
11
|
-
...OwnershipSchema,
|
12
|
-
...MetadataSchema,
|
13
|
-
// views: {
|
14
|
-
// type: Number,
|
15
|
-
// default: 0
|
16
|
-
// },
|
1
|
+
module.exports = (mongoose) => {
|
2
|
+
const EventSchema = new mongoose.Schema({
|
3
|
+
url: {
|
4
|
+
type: String,
|
5
|
+
required: true
|
6
|
+
},
|
17
7
|
cover: {
|
18
8
|
type: String,
|
19
9
|
},
|
@@ -21,11 +11,16 @@ module.exports = (db) => {
|
|
21
11
|
type: String,
|
22
12
|
required: true
|
23
13
|
},
|
14
|
+
status: {
|
15
|
+
type: String,
|
16
|
+
enum: ['draft','published','removed'],
|
17
|
+
default: 'draft',
|
18
|
+
required: true,
|
19
|
+
},
|
24
20
|
description: {
|
25
21
|
type: String,
|
26
22
|
required: true
|
27
23
|
},
|
28
|
-
|
29
24
|
content: {
|
30
25
|
type: Array
|
31
26
|
},
|
@@ -38,6 +33,41 @@ module.exports = (db) => {
|
|
38
33
|
type: Date,
|
39
34
|
}
|
40
35
|
},
|
36
|
+
tags: [{
|
37
|
+
type: String
|
38
|
+
}],
|
39
|
+
owner: {
|
40
|
+
type: {
|
41
|
+
type: String,
|
42
|
+
required: true
|
43
|
+
},
|
44
|
+
target: {
|
45
|
+
type: mongoose.Schema.Types.ObjectId,
|
46
|
+
ref: function (value) {
|
47
|
+
if (this.owner.type === 'user') return 'User';
|
48
|
+
if (this.owner.type === 'organization') return 'Organization';
|
49
|
+
},
|
50
|
+
required: true,
|
51
|
+
},
|
52
|
+
},
|
53
|
+
creator: {
|
54
|
+
hidden: {
|
55
|
+
type: Boolean,
|
56
|
+
required: true
|
57
|
+
},
|
58
|
+
type: {
|
59
|
+
type: String,
|
60
|
+
required: true
|
61
|
+
},
|
62
|
+
target: {
|
63
|
+
type: mongoose.Schema.Types.ObjectId,
|
64
|
+
ref: function (value) {
|
65
|
+
if (this.owner.type === 'user') return 'User';
|
66
|
+
if (this.owner.type === 'organization') return 'Organization';
|
67
|
+
},
|
68
|
+
required: true,
|
69
|
+
},
|
70
|
+
}
|
41
71
|
}, {
|
42
72
|
timestamps: {
|
43
73
|
currentTime: () => Date.now()
|
@@ -46,31 +76,7 @@ module.exports = (db) => {
|
|
46
76
|
|
47
77
|
EventSchema.index({ 'url': 1, 'name': 1, 'date.start': 1, 'date.end': -1, 'tags': 1, 'owner.target': 1, 'creator.target': 1 });
|
48
78
|
|
49
|
-
|
50
|
-
|
51
|
-
console.log(EventSchema)
|
52
|
-
|
53
|
-
// Проверяем, возвращены ли какие-либо документы
|
54
|
-
if (docs.length > 0) {
|
55
|
-
console.log('Post-aggregate hook triggered');
|
56
|
-
// console.log(docs)
|
57
|
-
try {
|
58
|
-
// Так как мы не можем использовать `this` для обновления внутри агрегации,
|
59
|
-
// мы должны выполнить обновление вручную для каждого соответствующего документа.
|
60
|
-
await Promise.all(docs.map(async (doc) => {
|
61
|
-
// Предполагается, что у каждого документа есть уникальный идентификатор '_id'
|
62
|
-
console.log(doc._id)
|
63
|
-
const updatedViews = await db.event.findOneAndUpdate({ _id: doc._id }, { $inc: { views: 1 } }).exec();
|
64
|
-
// console.log(updatedViews)
|
65
|
-
}));
|
66
|
-
} catch (error) {
|
67
|
-
console.error("Error updating views:", error);
|
68
|
-
}
|
69
|
-
}
|
70
|
-
});
|
71
|
-
|
72
|
-
const Event = db.mongoose.model("Event", EventSchema);
|
79
|
+
const Event = mongoose.model("Event", EventSchema);
|
73
80
|
|
74
81
|
return Event;
|
75
|
-
};
|
76
|
-
|
82
|
+
};
|
@@ -1,9 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
const CommonSchema = require('@pf/src/modules/globals/models/common.schema.js')
|
2
|
+
const EngagementSchema = require('@pf/src/modules/globals/models/engagement.schema.js')
|
3
|
+
const OwnershipSchema = require('@pf/src/modules/globals/models/ownership.schema.js')
|
4
|
+
const MetadataSchema = require('@pf/src/modules/globals/models/metadata.schema.js')
|
5
|
+
|
6
|
+
module.exports = (db) => {
|
7
|
+
|
8
|
+
const EventSchema = new db.mongoose.Schema({
|
9
|
+
...CommonSchema,
|
10
|
+
...EngagementSchema,
|
11
|
+
...OwnershipSchema,
|
12
|
+
...MetadataSchema,
|
13
|
+
// views: {
|
14
|
+
// type: Number,
|
15
|
+
// default: 0
|
16
|
+
// },
|
7
17
|
cover: {
|
8
18
|
type: String,
|
9
19
|
},
|
@@ -11,16 +21,11 @@ module.exports = (mongoose) => {
|
|
11
21
|
type: String,
|
12
22
|
required: true
|
13
23
|
},
|
14
|
-
status: {
|
15
|
-
type: String,
|
16
|
-
enum: ['draft','published','removed'],
|
17
|
-
default: 'draft',
|
18
|
-
required: true,
|
19
|
-
},
|
20
24
|
description: {
|
21
25
|
type: String,
|
22
26
|
required: true
|
23
27
|
},
|
28
|
+
|
24
29
|
content: {
|
25
30
|
type: Array
|
26
31
|
},
|
@@ -33,41 +38,6 @@ module.exports = (mongoose) => {
|
|
33
38
|
type: Date,
|
34
39
|
}
|
35
40
|
},
|
36
|
-
tags: [{
|
37
|
-
type: String
|
38
|
-
}],
|
39
|
-
owner: {
|
40
|
-
type: {
|
41
|
-
type: String,
|
42
|
-
required: true
|
43
|
-
},
|
44
|
-
target: {
|
45
|
-
type: mongoose.Schema.Types.ObjectId,
|
46
|
-
ref: function (value) {
|
47
|
-
if (this.owner.type === 'user') return 'User';
|
48
|
-
if (this.owner.type === 'organization') return 'Organization';
|
49
|
-
},
|
50
|
-
required: true,
|
51
|
-
},
|
52
|
-
},
|
53
|
-
creator: {
|
54
|
-
hidden: {
|
55
|
-
type: Boolean,
|
56
|
-
required: true
|
57
|
-
},
|
58
|
-
type: {
|
59
|
-
type: String,
|
60
|
-
required: true
|
61
|
-
},
|
62
|
-
target: {
|
63
|
-
type: mongoose.Schema.Types.ObjectId,
|
64
|
-
ref: function (value) {
|
65
|
-
if (this.owner.type === 'user') return 'User';
|
66
|
-
if (this.owner.type === 'organization') return 'Organization';
|
67
|
-
},
|
68
|
-
required: true,
|
69
|
-
},
|
70
|
-
}
|
71
41
|
}, {
|
72
42
|
timestamps: {
|
73
43
|
currentTime: () => Date.now()
|
@@ -76,7 +46,31 @@ module.exports = (mongoose) => {
|
|
76
46
|
|
77
47
|
EventSchema.index({ 'url': 1, 'name': 1, 'date.start': 1, 'date.end': -1, 'tags': 1, 'owner.target': 1, 'creator.target': 1 });
|
78
48
|
|
79
|
-
|
49
|
+
EventSchema.post('aggregate', async function(docs) {
|
50
|
+
|
51
|
+
console.log(EventSchema)
|
52
|
+
|
53
|
+
// Проверяем, возвращены ли какие-либо документы
|
54
|
+
if (docs.length > 0) {
|
55
|
+
console.log('Post-aggregate hook triggered');
|
56
|
+
// console.log(docs)
|
57
|
+
try {
|
58
|
+
// Так как мы не можем использовать `this` для обновления внутри агрегации,
|
59
|
+
// мы должны выполнить обновление вручную для каждого соответствующего документа.
|
60
|
+
await Promise.all(docs.map(async (doc) => {
|
61
|
+
// Предполагается, что у каждого документа есть уникальный идентификатор '_id'
|
62
|
+
console.log(doc._id)
|
63
|
+
const updatedViews = await db.event.findOneAndUpdate({ _id: doc._id }, { $inc: { views: 1 } }).exec();
|
64
|
+
// console.log(updatedViews)
|
65
|
+
}));
|
66
|
+
} catch (error) {
|
67
|
+
console.error("Error updating views:", error);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
});
|
71
|
+
|
72
|
+
const Event = db.mongoose.model("Event", EventSchema);
|
80
73
|
|
81
74
|
return Event;
|
82
|
-
};
|
75
|
+
};
|
76
|
+
|