- Fare LISTA MOVIMENTI più comprensibile
- Grafica Circuiti
This commit is contained in:
@@ -129,7 +129,7 @@ const AttivitaSchema = new Schema(
|
||||
//**ADDFIELD_ATTIVITA
|
||||
},
|
||||
...Reaction.getFieldsForReactions(),
|
||||
...MyGroup.getFieldsForAnnunci()
|
||||
...tools.getFieldsForAnnunci()
|
||||
}, { strict: false });
|
||||
|
||||
AttivitaSchema.index({ 'idapp': 1 });
|
||||
|
||||
@@ -394,7 +394,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
};
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, user) {
|
||||
CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, user, nummovTodownload) {
|
||||
|
||||
try {
|
||||
const { User } = require('../models/user');
|
||||
@@ -442,12 +442,15 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown).sort({ status: -1 }).lean();
|
||||
|
||||
const last_my_transactions = await Movement.getLastN_Transactions(idapp, nummovTodownload, username, '');
|
||||
|
||||
return {
|
||||
listcircuits,
|
||||
asked_circuits,
|
||||
refused_circuits,
|
||||
manage_mycircuits,
|
||||
mycircuits: user.profile.mycircuits,
|
||||
last_my_transactions,
|
||||
};
|
||||
|
||||
} catch (e) {
|
||||
@@ -664,6 +667,8 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const { MyGroup } = require('./mygroup');
|
||||
|
||||
const sendemail = require('../sendemail');
|
||||
|
||||
let ris = {
|
||||
@@ -785,10 +790,13 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
||||
await sendemail.sendEmail_RisRicevuti(myuserDest.lang, myuserDest, myuserDest.email, idapp, paramsrec);
|
||||
|
||||
} else if (extrarec.groupdest || extrarec.contoComDest) {
|
||||
const groupDestoContoCom = extrarec.groupdest ? extrarec.groupdest : (extrarec && extrarec.contoComDest ? extrarec.contoComDest : '');
|
||||
let arrusers = await MyGroup.getListAdminsByGroupName(idapp, groupDestoContoCom);
|
||||
if (arrusers.length <= 0)
|
||||
arrusers = await Circuit.getListAdminsByCircuitPath(idapp, groupDestoContoCom);
|
||||
|
||||
paramsrec.groupDestoContoCom = groupDestoContoCom;
|
||||
|
||||
for (let i = 0; i < arrusers.length; i++) {
|
||||
|
||||
let myuserDest = await User.getUserByUsername(idapp, arrusers[i].username);
|
||||
|
||||
@@ -137,6 +137,8 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
|
||||
}
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, true, groupname, contocom);
|
||||
|
||||
|
||||
|
||||
if (myaccount) {
|
||||
|
||||
let aggr1 = [
|
||||
@@ -741,24 +743,48 @@ MovementSchema.statics.checkIfCoinsAlreadySent = async function (notifId) {
|
||||
|
||||
};
|
||||
|
||||
MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz = 10) {
|
||||
MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz = 10, username = '', groupname = '', contocom = '') {
|
||||
const MyMovement = this;
|
||||
|
||||
// get last "numtransaz" transactions
|
||||
|
||||
let abilitaquerypersingolo = (username || groupname || contocom);
|
||||
|
||||
let querym2 = null;
|
||||
|
||||
if (abilitaquerypersingolo) {
|
||||
let v1 = [];
|
||||
|
||||
if (username) {
|
||||
v1.push({ 'userfrom.username': username },
|
||||
{ 'userto.username': username });
|
||||
}
|
||||
|
||||
if (groupname) {
|
||||
v1.push({ 'groupfrom.groupname': groupname },
|
||||
{ 'groupto.groupname': groupname });
|
||||
}
|
||||
if (contocom) {
|
||||
v1.push({ 'contocomfrom.name': contocom },
|
||||
{ 'contocomto.name': contocom });
|
||||
}
|
||||
|
||||
querym2 = {
|
||||
$match:
|
||||
{ $or: v1 }
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
},
|
||||
$match: { idapp },
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
transactionDate: -1,
|
||||
}
|
||||
},
|
||||
{ $limit: numtransaz },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'accounts',
|
||||
@@ -968,40 +994,46 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$project:
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitfrom.name': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'circuitto.name': 1,
|
||||
'userfrom.verified_by_aportador': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
'userto.verified_by_aportador': 1,
|
||||
'groupfrom.groupname': 1,
|
||||
'groupfrom.verified_by_aportador': 1,
|
||||
'groupfrom.title': 1,
|
||||
'groupfrom.photos': 1,
|
||||
'groupto.groupname': 1,
|
||||
'groupto.title': 1,
|
||||
'groupto.photos': 1,
|
||||
'groupto.verified_by_aportador': 1,
|
||||
'contocomfrom.path': 1,
|
||||
'contocomfrom.name': 1,
|
||||
'contocomto.path': 1,
|
||||
'contocomto.name': 1,
|
||||
},
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
if (querym2)
|
||||
aggr1.push(querym2);
|
||||
|
||||
if (numtransaz)
|
||||
aggr1.push({ $limit: numtransaz });
|
||||
|
||||
aggr1.push({
|
||||
$project:
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitfrom.name': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'circuitto.name': 1,
|
||||
'userfrom.verified_by_aportador': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
'userto.verified_by_aportador': 1,
|
||||
'groupfrom.groupname': 1,
|
||||
'groupfrom.verified_by_aportador': 1,
|
||||
'groupfrom.title': 1,
|
||||
'groupfrom.photos': 1,
|
||||
'groupto.groupname': 1,
|
||||
'groupto.title': 1,
|
||||
'groupto.photos': 1,
|
||||
'groupto.verified_by_aportador': 1,
|
||||
'contocomfrom.path': 1,
|
||||
'contocomfrom.name': 1,
|
||||
'contocomto.path': 1,
|
||||
'contocomto.name': 1,
|
||||
},
|
||||
});
|
||||
|
||||
const lastNtransac = await MyMovement.aggregate(aggr1);
|
||||
|
||||
/*
|
||||
@@ -1013,7 +1045,7 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
|
||||
circuito: string
|
||||
amount: number
|
||||
causale: string
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ const MyBachecaSchema = new Schema({
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions(),
|
||||
...MyGroup.getFieldsForAnnunci()
|
||||
...tools.getFieldsForAnnunci()
|
||||
});
|
||||
|
||||
MyBachecaSchema.pre('save', async function (next) {
|
||||
|
||||
@@ -92,7 +92,7 @@ const MyGoodSchema = new Schema({
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions(),
|
||||
...MyGroup.getFieldsForAnnunci()
|
||||
...tools.getFieldsForAnnunci()
|
||||
});
|
||||
|
||||
MyGoodSchema.pre('save', async function (next) {
|
||||
|
||||
@@ -66,7 +66,6 @@ const MyGroupSchema = new Schema({
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
//**ADDFIELD_MYGROUPS
|
||||
visibility: [
|
||||
{
|
||||
type: Number,
|
||||
@@ -125,11 +124,9 @@ const MyGroupSchema = new Schema({
|
||||
lastdate_reqRisGroup: {
|
||||
type: Date,
|
||||
},
|
||||
//**ADDFIELD_MYGROUPS
|
||||
|
||||
idMyGroup: {
|
||||
type: String,
|
||||
},
|
||||
// **ADDFIELD_MYGROUPS
|
||||
...tools.getFieldsForAnnunci(),
|
||||
|
||||
});
|
||||
|
||||
@@ -252,7 +249,6 @@ MyGroupSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
photos: 1,
|
||||
idCity: 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYGROUPS
|
||||
link_telegram: 1,
|
||||
note: 1,
|
||||
admins: 1,
|
||||
@@ -264,6 +260,7 @@ MyGroupSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
date_updated: 1,
|
||||
mycircuits: 1,
|
||||
lastdate_reqRisGroup: 1,
|
||||
//**ADDFIELD_MYGROUPS
|
||||
};
|
||||
|
||||
whatToShow = { ...whatToShow, ...shared_consts.ANNUNCI_FIELDS };
|
||||
@@ -647,7 +644,7 @@ MyGroupSchema.statics.getReceiveRISGroups = async function (idapp) {
|
||||
|
||||
|
||||
MyGroupSchema.statics.renameCircuitName = async function (idapp, oldcircuitname, newcircuitname) {
|
||||
|
||||
|
||||
return await this.updateMany({ idapp, 'mycircuits.circuitname': oldcircuitname }, { $set: { 'profile.mycircuits.$.circuitname': newcircuitname } });
|
||||
};
|
||||
|
||||
@@ -663,17 +660,6 @@ MyGroupSchema.statics.setReceiveRisGroup = async function (idapp, groupname) {
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getFieldsForAnnunci = function () {
|
||||
let annunciFields = {
|
||||
idMyGroup: {
|
||||
type: String,
|
||||
},
|
||||
// **ADDFIELD_MYGROUPS
|
||||
};
|
||||
|
||||
return annunciFields;
|
||||
};
|
||||
|
||||
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
|
||||
|
||||
MyGroup.createIndexes((err) => {
|
||||
|
||||
@@ -99,7 +99,7 @@ const MyHospSchema = new Schema({
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions(),
|
||||
...MyGroup.getFieldsForAnnunci()
|
||||
...tools.getFieldsForAnnunci()
|
||||
});
|
||||
|
||||
MyHospSchema.pre('save', async function (next) {
|
||||
|
||||
@@ -99,7 +99,7 @@ const MySkillSchema = new Schema(
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions(),
|
||||
...MyGroup.getFieldsForAnnunci()
|
||||
...tools.getFieldsForAnnunci()
|
||||
}, { strict: false });
|
||||
|
||||
MySkillSchema.index({ 'idapp': 1 });
|
||||
|
||||
@@ -15,6 +15,9 @@ const { Settings } = require('../models/settings');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
var ObjectId = mongoose.Types.ObjectId;
|
||||
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true;
|
||||
@@ -68,8 +71,8 @@ StatSchema.statics.updateStats = async function (datastat) {
|
||||
|
||||
datastat.last_transactions.forEach(function (mov) {
|
||||
let ris = tools.getStringaConto(mov)
|
||||
mov.myfrom = ris.myfrom
|
||||
mov.myto = ris.myto
|
||||
mov.userfrom = ris.userfrom
|
||||
mov.userto = ris.userto
|
||||
mov.tipocontofrom = ris.tipocontofrom
|
||||
mov.tipocontoto = ris.tipocontoto
|
||||
});
|
||||
@@ -113,11 +116,12 @@ StatSchema.statics.calculateStats = async function (idapp) {
|
||||
};
|
||||
|
||||
// Trova il record di oggi:
|
||||
const trova_se_oggi = await Stat.findOne({ idapp, date_created: { $gte: new Date(new Date().setHours(0, 0, 0, 0)) } });
|
||||
const trova_se_oggi = await Stat.findOne({ idapp, date_created: { $gte: new Date(new Date().setHours(0, 0, 0, 0)) } }).lean();
|
||||
|
||||
if (trova_se_oggi) {
|
||||
// Aggiorna il record di oggi:
|
||||
await Stat.updateOne({ _id: trova_se_oggi._id }, { $set: datastat });
|
||||
const ris = await Stat.findOneAndUpdate({ _id: trova_se_oggi._id }, { $set: datastat }, { new: true });
|
||||
console.log('ris', ris);
|
||||
} else {
|
||||
// Aggiungi un nuovo record:
|
||||
await Stat.insertMany([datastat]);
|
||||
|
||||
@@ -5614,7 +5614,7 @@ UserSchema.statics.addExtraInfo = async function (idapp, recUser, recUserSave, v
|
||||
|
||||
// Circuit>
|
||||
|
||||
const circuitobj = await Circuit.getCircuitsByUsername(idapp, recUser.username, recUser);
|
||||
const circuitobj = await Circuit.getCircuitsByUsername(idapp, recUser.username, recUser, 5);
|
||||
|
||||
const useraccounts = await Account.getUserAccounts(idapp, recUser.username);
|
||||
|
||||
|
||||
@@ -890,8 +890,9 @@ router.post('/circuits', authenticate, (req, res) => {
|
||||
const username = req.user.username;
|
||||
idapp = req.body.idapp;
|
||||
locale = req.body.locale;
|
||||
nummovTodownload = req.body.nummovTodownload;
|
||||
|
||||
return Circuit.getCircuitsByUsername(idapp, username, req.user).then((ris) => {
|
||||
return Circuit.getCircuitsByUsername(idapp, username, req.user, nummovTodownload).then((ris) => {
|
||||
res.send(ris);
|
||||
}).catch((e) => {
|
||||
tools.mylog('ERRORE IN circuits: ' + e.message);
|
||||
|
||||
@@ -319,6 +319,7 @@ module.exports = {
|
||||
transactionDate: tools.getstrDate_DD_MM_YYYY(myrec.transactionDate),
|
||||
symbol: myrec.symbol,
|
||||
causale: myrec.causale,
|
||||
groupDestoContoCom: myrec.groupDestoContoCom,
|
||||
};
|
||||
|
||||
mylocalsconf = this.setParamsForTemplate(userDest, mylocalsconf);
|
||||
|
||||
@@ -5609,39 +5609,44 @@ module.exports = {
|
||||
getStringaConto(mov) {
|
||||
|
||||
let mystr = ''
|
||||
let myfrom = ''
|
||||
let myto = ''
|
||||
let userfrom = ''
|
||||
let userto = ''
|
||||
|
||||
let profilefrom = null
|
||||
let profileto = null
|
||||
|
||||
let tipocontofrom = shared_consts.AccountType.USER
|
||||
let tipocontoto = shared_consts.AccountType.USER
|
||||
|
||||
if (mov.contocomfrom && mov.contocomfrom.name) {
|
||||
myfrom += mov.contocomfrom.name + ' '
|
||||
userfrom += mov.contocomfrom.name
|
||||
tipocontofrom = shared_consts.AccountType.COMMUNITY_ACCOUNT
|
||||
}
|
||||
if (mov.groupfrom) {
|
||||
myfrom += mov.groupfrom.groupname + ' '
|
||||
userfrom += mov.groupfrom.groupname
|
||||
tipocontofrom = shared_consts.AccountType.COLLECTIVE_ACCOUNT
|
||||
}
|
||||
if (mov.userfrom) {
|
||||
myfrom += mov.userfrom.username + ' '
|
||||
userfrom += mov.userfrom.username
|
||||
profilefrom = mov.userfrom.profile
|
||||
}
|
||||
|
||||
if (mov.contocomto && mov.contocomto.name) {
|
||||
myto += mov.contocomto.name + ' '
|
||||
userto += mov.contocomto.name
|
||||
tipocontoto = shared_consts.AccountType.COMMUNITY_ACCOUNT
|
||||
}
|
||||
if (mov.groupto) {
|
||||
myto += mov.groupto.groupname + ' '
|
||||
userto += mov.groupto.groupname
|
||||
tipocontoto = shared_consts.AccountType.COLLECTIVE_ACCOUNT
|
||||
}
|
||||
if (mov.userto) {
|
||||
myto += mov.userto.username + ' '
|
||||
userto += mov.userto.username
|
||||
profileto = mov.userto.profile
|
||||
}
|
||||
|
||||
// mystr = t('movement.from') + myfrom + ' ' + t('movement.to') + myto
|
||||
// mystr = t('movement.from') + userfrom + ' ' + t('movement.to') + userto
|
||||
|
||||
return { myfrom, myto, tipocontofrom, tipocontoto }
|
||||
return { userfrom: {profile: profilefrom, username: userfrom}, userto: {profile: profileto, username: userto}, tipocontofrom, tipocontoto }
|
||||
},
|
||||
|
||||
ImageDownloader,
|
||||
@@ -5685,5 +5690,21 @@ module.exports = {
|
||||
return 'it';
|
||||
},
|
||||
|
||||
getFieldsForAnnunci() {
|
||||
let annunciFields = {
|
||||
idMyGroup: {
|
||||
type: String,
|
||||
},
|
||||
expiryDateAdv: {
|
||||
type: Date,
|
||||
},
|
||||
enableExpiringAdv: {
|
||||
type: Boolean,
|
||||
},
|
||||
// **ADDFIELD_ANNUNCI
|
||||
};
|
||||
|
||||
return annunciFields;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@@ -177,7 +177,9 @@ module.exports = {
|
||||
|
||||
ANNUNCI_FIELDS: {
|
||||
idMyGroup: 1,
|
||||
// **ADDFIELD_MYGROUPS
|
||||
expiryDateAdvert: 1,
|
||||
|
||||
// **ADDFIELD_ANNUNCI
|
||||
},
|
||||
|
||||
// Condivise
|
||||
|
||||
Reference in New Issue
Block a user