- Pagina MySkills personale
This commit is contained in:
@@ -118,8 +118,7 @@ CitySchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
|
||||
let filterfind = {comune: {$regex: '^' + strfind, $options: 'i'}};
|
||||
|
||||
const ris = await City.find(filterfind, {comune: 1, prov: 1, reg: 1}).lean().limit(10);
|
||||
|
||||
let ris = await City.find(filterfind, {comune: 1, prov: 1, reg: 1}).lean().limit(10);
|
||||
|
||||
return [...risexact, ...ris];
|
||||
|
||||
|
||||
@@ -35,9 +35,6 @@ const MySkillSchema = new Schema({
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
idSector: {
|
||||
type: Number,
|
||||
},
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
@@ -98,6 +95,7 @@ MySkillSchema.pre('save', async function(next) {
|
||||
});
|
||||
|
||||
MySkillSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const MySkill = this;
|
||||
|
||||
const query = [
|
||||
{$match: {idapp}},
|
||||
@@ -154,6 +152,284 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getMySkillByIdkill = function (idapp, idSkill) {
|
||||
const MySkill = this;
|
||||
|
||||
const query = [
|
||||
{
|
||||
"$match": {
|
||||
"$and": [
|
||||
{
|
||||
"_id": parseInt(idSkill)
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"$match": {
|
||||
"idapp": idapp
|
||||
}
|
||||
},
|
||||
{
|
||||
"$sort": {
|
||||
"desc": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"myId1": {
|
||||
"$toObjectId": "$userId"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "users",
|
||||
"localField": "myId1",
|
||||
"foreignField": "_id",
|
||||
"as": "user"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$user",
|
||||
0
|
||||
]
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recSkill": 1,
|
||||
"sector": 1,
|
||||
"idSkill": 1,
|
||||
"idSubSkill": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"numLevel": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"subTitle": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "skills",
|
||||
"localField": "idSkill",
|
||||
"foreignField": "_id",
|
||||
"as": "recSkill"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$recSkill",
|
||||
0
|
||||
]
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recSkill": 1,
|
||||
"sector": 1,
|
||||
"idSkill": 1,
|
||||
"idSubSkill": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"numLevel": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"subTitle": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "sectors",
|
||||
"localField": "recSkill.idSector",
|
||||
"foreignField": "_id",
|
||||
"as": "sector"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$sector",
|
||||
0
|
||||
]
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recSkill": 1,
|
||||
"sector": 1,
|
||||
"idSkill": 1,
|
||||
"idSubSkill": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"numLevel": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"subTitle": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "subskills",
|
||||
"localField": "idSubSkill",
|
||||
"foreignField": "_id",
|
||||
"as": "myskill"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$myskill",
|
||||
0
|
||||
]
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recSkill": 1,
|
||||
"sector": 1,
|
||||
"idSkill": 1,
|
||||
"idSubSkill": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"numLevel": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"subTitle": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "cities",
|
||||
"localField": "idCity",
|
||||
"foreignField": "_id",
|
||||
"as": "mycities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$mycities",
|
||||
0
|
||||
]
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recSkill": 1,
|
||||
"sector": 1,
|
||||
"idSkill": 1,
|
||||
"idSubSkill": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"numLevel": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"subTitle": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
return MySkill.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const MySkill = mongoose.model('MySkill', MySkillSchema);
|
||||
|
||||
module.exports = {MySkill};
|
||||
|
||||
@@ -225,6 +225,12 @@ const UserSchema = new mongoose.Schema({
|
||||
username_telegram: {
|
||||
type: String,
|
||||
},
|
||||
firstname_telegram: {
|
||||
type: String,
|
||||
},
|
||||
lastname_telegram: {
|
||||
type: String,
|
||||
},
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
@@ -1660,6 +1666,24 @@ UserSchema.statics.SetTelegramIdSuccess = async function(idapp, id, teleg_id) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.setUsernameTelegram = async function(idapp, id, username_telegram, firstname_telegram, lastname_telegram) {
|
||||
const User = this;
|
||||
|
||||
const fields_to_update = {
|
||||
'profile.username_telegram': username_telegram,
|
||||
'profile.firstname_telegram': firstname_telegram,
|
||||
'profile.lastname_telegram': lastname_telegram,
|
||||
};
|
||||
|
||||
return User.findOneAndUpdate({
|
||||
idapp,
|
||||
_id: id,
|
||||
}, {$set: fields_to_update}, {new: false}).then((record) => {
|
||||
return record;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getLangByIndOrder = async function(idapp, ind_order) {
|
||||
const User = this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user