Attivare gli scambi RIS solo se si è aggiunto almeno 1 bene o 1 servizio.
This commit is contained in:
@@ -1492,6 +1492,7 @@ UserSchema.statics.getUserProfileByUsername = async function(
|
|||||||
'profile.born_city_id': 1,
|
'profile.born_city_id': 1,
|
||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
|
'profile.calc': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
'useraport.username': 1,
|
'useraport.username': 1,
|
||||||
@@ -1531,6 +1532,7 @@ UserSchema.statics.getUserProfileByUsername = async function(
|
|||||||
'profile.born_city_id': 1,
|
'profile.born_city_id': 1,
|
||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
|
'profile.calc': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
'useraport.username': 1,
|
'useraport.username': 1,
|
||||||
@@ -1571,6 +1573,7 @@ UserSchema.statics.getUserProfileByUsername = async function(
|
|||||||
'profile.born_city_id': 1,
|
'profile.born_city_id': 1,
|
||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
|
'profile.calc': 1,
|
||||||
'mycities': 1,
|
'mycities': 1,
|
||||||
'comune': 1,
|
'comune': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
@@ -1647,8 +1650,11 @@ UserSchema.statics.getUserProfileByUsername = async function(
|
|||||||
try {
|
try {
|
||||||
const ris = await User.aggregate(query);
|
const ris = await User.aggregate(query);
|
||||||
|
|
||||||
if (ris && ris.length > 0)
|
if (ris && ris.length > 0) {
|
||||||
|
|
||||||
|
ris[0].profile.calc = await User.calcOtherByUser(idapp, ris[0]._id);
|
||||||
return ris[0];
|
return ris[0];
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -2448,6 +2454,7 @@ function getWhatToShow(idapp, username) {
|
|||||||
'profile.born_city_id': 1,
|
'profile.born_city_id': 1,
|
||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
|
'profile.calc': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
};
|
};
|
||||||
@@ -2468,6 +2475,7 @@ function getWhatToShow_Unknown(idapp, username) {
|
|||||||
'profile.sex': 1,
|
'profile.sex': 1,
|
||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
|
'profile.calc': 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2487,6 +2495,7 @@ UserSchema.statics.getWhatToShow_IfFriends = async function(idapp, username) {
|
|||||||
'profile.sex': 1,
|
'profile.sex': 1,
|
||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
|
'profile.calc': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
date_report: 1,
|
date_report: 1,
|
||||||
username_who_report: 1,
|
username_who_report: 1,
|
||||||
@@ -3998,6 +4007,9 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
|
|||||||
|
|
||||||
recUser._doc.calcstat = await User.calculateStat(idapp, recUser.username);
|
recUser._doc.calcstat = await User.calculateStat(idapp, recUser.username);
|
||||||
|
|
||||||
|
recUser._doc.profile.calc = await User.calcOtherByUser(idapp, recUser._id);
|
||||||
|
|
||||||
|
|
||||||
return recUser._doc;
|
return recUser._doc;
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -4007,6 +4019,22 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
|
|||||||
return recUser;
|
return recUser;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UserSchema.statics.calcOtherByUser = async function(idapp, userId) {
|
||||||
|
|
||||||
|
const {MySkill} = require('../models/myskill');
|
||||||
|
const {MyGood} = require('../models/mygood');
|
||||||
|
|
||||||
|
let calc = {};
|
||||||
|
|
||||||
|
let numgoods = await MyGood.countDocuments({idapp, userId});
|
||||||
|
let numskills = await MySkill.countDocuments({idapp, userId});
|
||||||
|
|
||||||
|
calc.numGoodsAndServices = numgoods + numskills;
|
||||||
|
|
||||||
|
return calc;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
UserSchema.statics.createNewSubRecord = async function(idapp, req) {
|
UserSchema.statics.createNewSubRecord = async function(idapp, req) {
|
||||||
const User = this;
|
const User = this;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user