@duvdu-v1/duvdu 1.1.227 → 1.1.228
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -69,6 +69,8 @@ const userSchema = new mongoose_1.Schema({
|
|
|
69
69
|
projectsView: { type: Number, default: 0 },
|
|
70
70
|
haveInvitation: { type: Boolean, default: false },
|
|
71
71
|
faceRecognition: { type: String, default: null },
|
|
72
|
+
projectsCount: { type: Number, default: 0 },
|
|
73
|
+
favoriteCount: { type: Number, default: 0 },
|
|
72
74
|
}, {
|
|
73
75
|
timestamps: true,
|
|
74
76
|
collection: model_names_1.MODELS.user,
|
|
@@ -88,7 +90,9 @@ const userSchema = new mongoose_1.Schema({
|
|
|
88
90
|
userSchema.pre('save', function (next) {
|
|
89
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
92
|
if (this.isModified('acceptedProjectsCounter') ||
|
|
91
|
-
this.isModified('likes')
|
|
93
|
+
this.isModified('likes') ||
|
|
94
|
+
this.isModified('projectsCount') ||
|
|
95
|
+
this.isModified('favoriteCount')) {
|
|
92
96
|
yield (0, rank_service_1.updateRankForUser)(this);
|
|
93
97
|
}
|
|
94
98
|
next();
|
|
@@ -10,14 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.recalculateAllUsersRanks = exports.updateRankForUser = void 0;
|
|
13
|
-
const allProjects_model_1 = require("../models/allProjects.model");
|
|
14
|
-
const favourites_model_1 = require("../models/favourites.model");
|
|
15
13
|
const ranks_model_1 = require("../models/ranks.model");
|
|
16
14
|
const User_model_1 = require("../models/User.model");
|
|
17
15
|
const updateRankForUser = (user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
16
|
// get all user stats
|
|
19
|
-
const projectsCount =
|
|
20
|
-
const favoriteCount =
|
|
17
|
+
const projectsCount = user.projectsCount;
|
|
18
|
+
const favoriteCount = user.favoriteCount;
|
|
21
19
|
const projectsLiked = user.likes;
|
|
22
20
|
const acceptedProjectsCounter = user.acceptedProjectsCounter;
|
|
23
21
|
// Find current rank that matches ALL criteria
|
package/build/types/User.d.ts
CHANGED