- se iOS non ricarica la pagina ma disinstalla il SW precedente e chiede di riavviare

- fixed: Creando un Conto di Gruppo, pare che venga impostato anche l'username... invece dev'essere solo il groupname
-
This commit is contained in:
Surya Paolo
2023-10-03 23:16:52 +02:00
parent d6303f5880
commit 536fbd1752
7 changed files with 187 additions and 26 deletions

View File

@@ -21,3 +21,5 @@ Dom 25/06 ORE 16:11: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
Ven 29/09 ORE 23:18: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
Mar 03/10 ORE 22:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!

View File

@@ -237,7 +237,7 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
myaccount = new Account({
_id: new ObjectID().toString(),
idapp,
username,
username: (!groupname && !contocom) ? username : '',
groupname,
contocom,
circuitId: mycircuit._id,

View File

@@ -4,7 +4,6 @@ const Schema = mongoose.Schema;
const i18n = require('i18n');
const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
@@ -67,6 +66,150 @@ reactionSchema.statics.getFieldsForReactions = function () {
return reactionsField;
};
reactionSchema.statics.getReactionsCounts = async function (mytable, idapp, idrec, numtab) {
let query = [];
try {
query =
[
{
$match: {
_id: idrec,
},
},
{
$lookup: {
from: "reactions",
let: {
tab: numtab,
id: '$_id',
},
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$idrec', idrec] },
{ $eq: ['$tab', numtab] },
{ $eq: ['$idapp', idapp] },
],
},
},
},
{
$group: {
_id: "$idrec",
numseen: {
$sum: {
$cond: {
if: { $ifNull: ["$seen", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numfav: {
$sum: {
$cond: {
if: { $ifNull: ["$fav", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numbook: {
$sum: {
$cond: {
if: { $ifNull: ["$book", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numattend: {
$sum: {
$cond: {
if: { $ifNull: ["$attend", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
}
},
},
],
as: 'myreact',
},
},
{
$unwind: {
path: "$myreact",
preserveNullAndEmptyArrays: true,
},
},
];
const ris = await mytable.aggregate(query);
return ris ? ris[0]: null;
} catch (e) {
}
};
reactionSchema.statics.updateReactionsCounts = async function () {
const globalTables = require('../tools/globalTables');
console.log('INIZIO - updateReactionsCounts');
try {
for (const tablestr of shared_consts.TABLES_REACTIONS) {
const numtab = tools.getNumTabByTable(tablestr);
const mytable = globalTables.getTableByTableName(tablestr);
const arrrec = await mytable.find({});
console.log(' updateReactionsCounts tabella', tablestr);
for (const rec of arrrec) {
// Calcola
const ris = await Reaction.getReactionsCounts(mytable, idapp, rec._id, numtab);
if (ris && ris.myreact) {
risupdate = await mytable.updateOne({ _id: rec._id }, {
$set: {
numseen: ris.myreact.numseen | 0,
numfav: ris.myreact.numfav | 0,
numbook: ris.myreact.numbook | 0,
numattend: ris.myreact.numattend | 0,
}
})
}
}
}
console.log('FINE - updateReactionsCounts');
} catch (err) {
console.error(err);
}
};
;
reactionSchema.statics.getFieldsForSearch = function () {
return [
{ field: 'username', type: tools.FieldType.string }];

View File

@@ -5021,22 +5021,22 @@ UserSchema.statics.moverecordsFavorite = async function (tab) {
};
UserSchema.statics.removerecordsFavorite = async function () {
// Rimuovi i record del vecchio schema
const attivacanc = true;
// Rimuovi i record del vecchio schema
const attivacanc = true;
if (attivacanc) {
const queryfind = { idapp: '13' };
await User.findOneAndUpdate(queryfind, {
$set:
{
'profile.favorite': [],
'profile.bookmark': [],
'profile.attend': [],
'profile.seen': []
},
});
if (attivacanc) {
const queryfind = { idapp: '13' };
await User.findOneAndUpdate(queryfind, {
$set:
{
'profile.favorite': [],
'profile.bookmark': [],
'profile.attend': [],
'profile.seen': []
},
});
}
}
};
UserSchema.statics.updateVersion = async function (userversion, recUser) {

View File

@@ -42,7 +42,7 @@ module.exports = {
{_id: 40, idSector: [7], descr: 'Muratore'},
{_id: 41, idSector: [7], descr: 'Imbianchino'},
{_id: 42, idSector: [7], descr: 'Elettricista - TV'},
{_id: 43, idSector: [7], descr: 'Falegname e restauro'},
{_id: 43, idSector: [7], descr: 'Falegname'},
{_id: 44, idSector: [7], descr: 'Fabbro'},
{_id: 45, idSector: [7], descr: 'Arredamento'},
{_id: 46, idSector: [7], descr: 'Idraulico'},
@@ -122,7 +122,10 @@ module.exports = {
{_id: 127, idSector: [1], descr: 'Stanza in affitto'},
{_id: 128, idSector: [1], descr: 'Stanza in condivisione'},
{_id: 129, idSector: [3], descr: 'Home Restaurant'},
{_id: 130, idSector: [7], descr: 'Pompe di calore'},
{_id: 131, idSector: [7], descr: 'Impianti Fotovoltaici'},
{_id: 130, idSector: [7], descr: 'Pannelli Solari'},
{_id: 131, idSector: [7], descr: 'Pompe di calore'},
{_id: 132, idSector: [7], descr: 'Impianti Fotovoltaici'},
{_id: 133, idSector: [7], descr: 'Restauro'},
{_id: 134, idSector: [7], descr: 'Altro'},
],
};

View File

@@ -25,14 +25,14 @@ const _ = require('lodash');
const reg = require('../reg/registration');
const { authenticate, authenticate_noerror, authenticate_noerror } = require('../middleware/authenticate');
const { authenticate, authenticate_noerror } = require('../middleware/authenticate');
const TypedError = require('../modules/ErrorHandler');
const globalTables = require('../tools/globalTables');
const mongoose = require('mongoose').set('debug', false);
router.post('/cmd', authenticate_noerror_noerror, async (req, res) => {
router.post('/cmd', authenticate_noerror, async (req, res) => {
const mydata = req.body.mydata;
const idapp = req.body.idapp;

View File

@@ -28,7 +28,8 @@ const _ = require('lodash');
const reg = require('../reg/registration');
const { authenticate } = require('../middleware/authenticate');
const { authenticate, authenticate_noerror } = require('../middleware/authenticate');
const Cart = require('../models/cart');
const CartClass = require('../modules/Cart');
@@ -428,7 +429,7 @@ router.post('/receiveris', authenticate, (req, res) => {
};
});
router.post('/profile', (req, res) => {
router.post('/profile', authenticate_noerror, (req, res) => {
const usernameOrig = req.user ? req.user.username : '';
const perm = req.user ? req.user.perm : tools.Perm.PERM_NONE;
const username = req.body['username'];
@@ -447,8 +448,16 @@ router.post('/profile', (req, res) => {
then((ris) => {
return User.getFriendsByUsername(idapp, usernameOrig).
then((friends) => {
res.send({ user: ris, friends });
then(async (friends) => {
if (username === usernameOrig) {
const userprofile = await User.getExtraInfoByUsername(idapp, username);
ris.profile = userprofile;
}
return { ris, friends };
}).then(tot => {
return res.send({ user: tot.ris, friends: tot.friends });
});
}).catch((e) => {
@@ -716,7 +725,7 @@ router.post('/updatesaldo', authenticate, async (req, res) => {
userprofile
}
return res.send({ris});
return res.send({ ris });
} catch (e) {
tools.mylog('ERRORE IN updatesaldo: ' + e);
@@ -833,6 +842,7 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
const populate = require('../populate/populate');
const globalTables = require('../tools/globalTables');
const { Reaction } = require('../models/reaction');
let mystr = '';
@@ -1190,6 +1200,9 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
// Passa le tabelle da users sulle nuove tabelle:
await User.removerecordsFavorite();
} else if (mydata.dbop === 'updateReactionsCounts') {
await Reaction.updateReactionsCounts();
} else if (mydata.dbop === 'newRecordsFav') {
// Passa le tabelle da users sulle nuove tabelle:
await User.moverecordsFavorite(1);