Lista Navi
This commit is contained in:
@@ -43,15 +43,6 @@ const NaveSchema = new mongoose.Schema({
|
||||
parent_id: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
},
|
||||
/*date_start: {
|
||||
type: Date
|
||||
},
|
||||
date_gift_chat_open: {
|
||||
type: Date
|
||||
},
|
||||
link_chat: {
|
||||
type: String,
|
||||
},*/
|
||||
sent_msg_howto_make_gift: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@@ -80,18 +71,6 @@ const NaveSchema = new mongoose.Schema({
|
||||
note: {
|
||||
type: String
|
||||
},
|
||||
/* provvisoria: {
|
||||
type: Boolean
|
||||
},
|
||||
note_bot: {
|
||||
type: String
|
||||
},
|
||||
note_interne: {
|
||||
type: String
|
||||
},
|
||||
tutor: {
|
||||
type: String
|
||||
}*/
|
||||
});
|
||||
|
||||
NaveSchema.statics.getTotInLista = async function (idapp) {
|
||||
@@ -115,6 +94,20 @@ NaveSchema.statics.findByIndOrder = function (idapp, ind_order) {
|
||||
}
|
||||
};
|
||||
|
||||
NaveSchema.statics.findByIndOrderAndNumTess = function (idapp, ind_order, num_tess) {
|
||||
const Nave = this;
|
||||
|
||||
try {
|
||||
return Nave.findOne({
|
||||
idapp,
|
||||
ind_order,
|
||||
num_tess,
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
NaveSchema.statics.findById = function (idapp, id) {
|
||||
const Nave = this;
|
||||
|
||||
@@ -140,7 +133,9 @@ NaveSchema.statics.findByIndPrimario = function (idapp, indprimario) {
|
||||
|
||||
NaveSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'ind_order', type: tools.FieldType.number },
|
||||
{ field: 'col', type: tools.FieldType.number }]
|
||||
{ field: 'riga', type: tools.FieldType.number },
|
||||
{ field: 'col', type: tools.FieldType.number },
|
||||
{ field: '_id', type: tools.FieldType.exact }]
|
||||
};
|
||||
|
||||
NaveSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
@@ -365,7 +360,7 @@ NaveSchema.statics.findGeneric = function (myrigacol) {
|
||||
myarr = { ...newrec._doc, ...rec[0]._doc };
|
||||
return myarr;
|
||||
} else {
|
||||
let myarr = null;
|
||||
let myarr = rec[0];
|
||||
if (!!newrec) {
|
||||
if (rec[0]._doc === undefined)
|
||||
myarr = { ...newrec._doc, ...rec[0] };
|
||||
@@ -426,6 +421,7 @@ function getQueryProj(myfilter) {
|
||||
username: 1,
|
||||
'profile.paymenttypes': 1,
|
||||
'profile.email_paypal': 1,
|
||||
'profile.cell': 1,
|
||||
made_gift: 1,
|
||||
sent_msg_howto_make_gift: 1,
|
||||
date_made_gift: 1,
|
||||
@@ -741,17 +737,19 @@ NaveSchema.statics.getNavePos = async function (idapp, riga, col, solorecord, in
|
||||
if (indfuoco === 1)
|
||||
primofuoco = recfuoco;
|
||||
|
||||
let symbol = '';
|
||||
if (recfuoco.made_gift) {
|
||||
symbol = '🎁';
|
||||
donifatti++;
|
||||
}
|
||||
if (!!recfuoco && recmediatore) {
|
||||
if (recfuoco.ind_order === recmediatore.ind_order && recfuoco.num_tess === 2) {
|
||||
mystr += await getusertextbyrec(recfuoco, '', tools.get__('RITESSITURA', lang), miariga, miacol, '') + tools.ACAPO;
|
||||
} else {
|
||||
mystr += await getusertextbyrec(recfuoco, symbol, 'D', miariga, miacol, indfuoco) + tools.ACAPO;
|
||||
donitotali++;
|
||||
if (!!recfuoco) {
|
||||
let symbol = '';
|
||||
if (recfuoco.made_gift) {
|
||||
symbol = '🎁';
|
||||
donifatti++;
|
||||
}
|
||||
if (!!recfuoco && recmediatore) {
|
||||
if (recfuoco.ind_order === recmediatore.ind_order && recfuoco.num_tess === 2) {
|
||||
mystr += await getusertextbyrec(recfuoco, '', tools.get__('RITESSITURA', lang), miariga, miacol, '') + tools.ACAPO;
|
||||
} else {
|
||||
mystr += await getusertextbyrec(recfuoco, symbol, 'D', miariga, miacol, indfuoco) + tools.ACAPO;
|
||||
donitotali++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -769,7 +767,7 @@ NaveSchema.statics.getNavePos = async function (idapp, riga, col, solorecord, in
|
||||
// tools.gettranslate('PLACCA_TUTOR', lang)
|
||||
|
||||
if (!!recnavepersistente.tutor_namesurname)
|
||||
data += '👤 ' + tools.get__('Tutor che affianchèra il Mediatore', lang) + ': "' + recnavepersistente.tutor_namesurname + '"' + tools.ACAPO;
|
||||
data += '👤 ' + tools.get__('Tutor che affianchèra il Mediatore', lang) + ': "' + recnavepersistente.tutor_namesurname + '"' + tools.ACAPO;
|
||||
|
||||
data += '💬 ' + tools.get__('Giorno di Apertura GIFT CHAT', lang) + ': ' + tools.getstrDateLong(recnavepersistente.date_gift_chat_open) + tools.ACAPO;
|
||||
|
||||
@@ -852,7 +850,9 @@ NaveSchema.statics.showListaOrd = async function (idapp) {
|
||||
for (const rec of arrrec) {
|
||||
let recnavepersistente = await NavePersistente.findByRigaColByDonatore(idapp, rec.riga, rec.col, 0);
|
||||
if (!!recnavepersistente) {
|
||||
mystr += '[' + conta + '] [' + rec.riga + '.' + rec.col + '] ' + rec.ind_order + ' ' + rec.name + ' ' + rec.surname + ' (' + tools.getstrDateShort(recnavepersistente.date_start) + ')\n';
|
||||
mystr += '[' + conta + '] [' + rec.riga + '.' + rec.col + '] ' + rec.ind_order + ' ' + rec.name + ' ' + rec.surname + ' (' + tools.getstrDateShort(recnavepersistente.date_start) + ')';
|
||||
mystr += ' num_tess = ' + rec.num_tess;
|
||||
mystr += '\n';
|
||||
}
|
||||
conta++;
|
||||
}
|
||||
@@ -911,9 +911,13 @@ async function addRecordNaveByParams(params, siRitesse) {
|
||||
});
|
||||
myNave.created = new Date();
|
||||
|
||||
console.log('[' + params.riga + ',' + params.col + ']');
|
||||
// console.log('[' + params.riga + ',' + params.col + ']');
|
||||
// console.log('parent = [' + params.rigaparent + ',' + params.colparent + ']');
|
||||
|
||||
const recfindparent = await Nave.findByRigaCol(idapp, params.rigaparent, params.colparent, false);
|
||||
|
||||
// console.log('recfindparent = [' + recfindparent + ']');
|
||||
// console.table(recfindparent);
|
||||
if (!!recfindparent) {
|
||||
myNave.parent_id = recfindparent._id;
|
||||
} else {
|
||||
@@ -978,7 +982,7 @@ NaveSchema.statics.checkifDeveRitessersi = async function (recuser) {
|
||||
arrrec = await Nave.find({ idapp: recuser.idapp, ind_order: recuser.ind_order });
|
||||
|
||||
if (!!arrrec) {
|
||||
if (arrrec.length > 2) {
|
||||
if ((arrrec.length % 2) === 0) {
|
||||
// deveritessersi = await User.deveRitessersi(recuser.idapp, recuser.ind_order)
|
||||
deveritessersi = false;
|
||||
}
|
||||
@@ -1006,6 +1010,9 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
|
||||
params.colparent = Math.ceil(params.col / 2);
|
||||
params.rigaparent = params.riga - 1;
|
||||
|
||||
if (params.rigaparent === 0)
|
||||
params.colparent = 0;
|
||||
|
||||
myriga = params.riga;
|
||||
mycol = params.col;
|
||||
|
||||
@@ -1013,25 +1020,16 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
|
||||
if (inserito) {
|
||||
if (idapp === tools.AYNI) {
|
||||
if (((params.col) % 8) === 0) {
|
||||
// Trova se la persona di 3 livelli sopra, si deve ritessere
|
||||
let recmediatore = await Nave.findMediatoreByFuoco(idapp, myriga, mycol, 0);
|
||||
if (!!recmediatore) {
|
||||
const ris = await Nave.checkifDeveRitessersi(recmediatore);
|
||||
if (ris.num_tess >= 2) {
|
||||
console.log('E\' arrivato alla TERZA RITESSITURA, PERTANTO LO METTIAMO IN CODA... [riga=', params.riga, 'col', params.col, '] indorder=' + recmediatore.ind_order);
|
||||
// E' arrivato alla TERZA RITESSITURA, PERTANTO LO METTIAMO IN CODA...
|
||||
|
||||
//++Todo: TESSITURA????
|
||||
|
||||
//const risultato = await ListaIngresso.addUserInListaIngresso(idapp, recmediatore.ind_order, rec.lang, false, ris.num_tess);
|
||||
|
||||
} else {
|
||||
console.log('Si deve ritessere: [riga=', params.riga, 'col', params.col, ']');
|
||||
if (ris.deveritessersi) {
|
||||
console.log('Si deve ritesere: [riga=', params.riga, 'col', params.col, ']');
|
||||
if (ris.deveritessersi) {
|
||||
params.indprimario = recmediatore.indprimario;
|
||||
params.ind_order = recmediatore.ind_order;
|
||||
params.id = recmediatore._id;
|
||||
params.num_tess = ris.num_tess;
|
||||
params.num_tess = ris.num_tess + 1;
|
||||
|
||||
await addRecordNaveByParams(params, true);
|
||||
}
|
||||
@@ -1130,12 +1128,10 @@ NaveSchema.statics.checkIfDevoAggiungereInNave = async function (idapp) {
|
||||
const { ListaIngresso } = require('./listaingresso');
|
||||
|
||||
// Ottieni la lista Ordinata in base al numero d'invitati
|
||||
arrlista = await ListaIngresso.getProssimiInLista(idapp, false);
|
||||
arrlista = await ListaIngresso.getProssimiInLista(idapp, true);
|
||||
|
||||
for (const rec of arrlista) {
|
||||
if (rec.numinvitatiattivi >= 2) {
|
||||
await addUserToNave(idapp, rec);
|
||||
}
|
||||
await addUserToNave(idapp, rec);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1157,7 +1153,7 @@ NaveSchema.statics.pulisciNonPresenzeInNave = async function (idapp) {
|
||||
arrrec = await ListaIngresso.aggregate(myquery)
|
||||
.then(async (arrlista) => {
|
||||
for (const rec of arrlista) {
|
||||
const trovato = await Nave.findByIndOrder(idapp, rec.ind_order);
|
||||
const trovato = await Nave.findByIndOrderAndNumTess(idapp, rec.ind_order, rec.num_tess);
|
||||
if (!trovato) {
|
||||
let fields_to_update = { added: false };
|
||||
await ListaIngresso.findOneAndUpdate({ _id: rec._id }, { $set: fields_to_update }, { new: false });
|
||||
@@ -1171,6 +1167,31 @@ NaveSchema.statics.pulisciNonPresenzeInNave = async function (idapp) {
|
||||
|
||||
};
|
||||
|
||||
NaveSchema.statics.visuNaviUtentiEliminati = async function (idapp) {
|
||||
const Nave = this;
|
||||
|
||||
let numrec = 0;
|
||||
|
||||
const myquery = getQueryProj({ idapp });
|
||||
|
||||
arrrec = await Nave.aggregate(myquery).sort({ riga: 1, col: 1 });
|
||||
|
||||
let mystr = 'ELIMINATI: \n';
|
||||
let conta = 0;
|
||||
for (const rec of arrrec) {
|
||||
if (!rec.username) {
|
||||
let navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, rec.riga, rec.col, 0);
|
||||
mystr += '[' + conta + '] [NAVI ' + navepersistente.riga + '.' + navepersistente.col + '] [' + rec.riga + '.' + rec.col + '] ' + rec.ind_order;
|
||||
mystr += ' num_tess = ' + rec.num_tess;
|
||||
mystr += '\n';
|
||||
conta++;
|
||||
}
|
||||
}
|
||||
|
||||
return { mystr, num: conta };
|
||||
};
|
||||
|
||||
|
||||
NaveSchema.statics.getNaveByUser = async function (idapp, ind_order, lang, fuoco) {
|
||||
const Nave = this;
|
||||
|
||||
@@ -1195,19 +1216,17 @@ NaveSchema.statics.getNaveByUser = async function (idapp, ind_order, lang, fuoco
|
||||
return mystr;
|
||||
};
|
||||
|
||||
NaveSchema.statics.getNaveByRigaCol = async function (idapp, riganave, colnave) {
|
||||
NaveSchema.statics.getNaveByRigaCol = async function (idapp, rigapos, colpos) {
|
||||
const Nave = this;
|
||||
|
||||
const rigaprec = riganave;
|
||||
|
||||
rec = {};
|
||||
rec = await Nave.getPlaccaPerMediatore(idapp, riganave, colnave, true, rec);
|
||||
rec = await Nave.getPlaccaPerMediatore(idapp, rigapos, colpos, true, rec);
|
||||
|
||||
if (riganave < 4) {
|
||||
riganave = 4;
|
||||
colnave = 1;
|
||||
if (rigapos < 4) {
|
||||
rigapos = 4;
|
||||
colpos = 1;
|
||||
}
|
||||
rec = await Nave.getPlaccaPerDonatore(idapp, riganave, colnave, true, rec);
|
||||
rec = await Nave.getPlaccaPerDonatore(idapp, rigapos, colpos, true, rec);
|
||||
|
||||
return rec;
|
||||
};
|
||||
@@ -1215,8 +1234,8 @@ NaveSchema.statics.getNaveByRigaCol = async function (idapp, riganave, colnave)
|
||||
NaveSchema.statics.getDonatoridelSognatore = async function (idapp, riganave, colnave) {
|
||||
const Nave = this;
|
||||
|
||||
coldonatoreIni = calcval(riganave, colnave, 8) + (1);
|
||||
coldonatoreFine = calcval(riganave, colnave, 8) + (64);
|
||||
coldonatoreIni = ((colnave - 1) * 64) + (1);
|
||||
coldonatoreFine = coldonatoreIni + (64);
|
||||
|
||||
const myquery = getQueryProj({
|
||||
idapp,
|
||||
|
||||
Reference in New Issue
Block a user