+ Registered Users

+ UsersList Online
This commit is contained in:
Surya Paolo
2022-12-10 02:01:17 +01:00
parent 1cbec78536
commit 234fd8b00d
8 changed files with 1083 additions and 1026 deletions

View File

@@ -164,6 +164,7 @@ ExtraListSchema.statics.getUsersList = function (idapp) {
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
date_reg: 1,
})

View File

@@ -6,7 +6,7 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -21,7 +21,7 @@ const MyBachecaSchema = new Schema({
type: String,
required: true,
},
userId: {type: Schema.Types.ObjectId, ref: 'User'},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
idSector: {
type: Number,
},
@@ -86,9 +86,9 @@ const MyBachecaSchema = new Schema({
},
});
MyBachecaSchema.pre('save', async function(next) {
MyBachecaSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyBacheca.findOne().limit(1).sort({_id: -1});
const myrec = await MyBacheca.findOne().limit(1).sort({ _id: -1 });
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
@@ -105,12 +105,12 @@ MyBachecaSchema.pre('save', async function(next) {
next();
});
MyBachecaSchema.statics.findAllIdApp = async function(idapp) {
MyBachecaSchema.statics.findAllIdApp = async function (idapp) {
const MyBacheca = this;
const query = [
{$match: {idapp}},
{$sort: {descr: 1}},
{ $match: { idapp } },
{ $sort: { descr: 1 } },
];
return await MyBacheca.aggregate(query).then((arrrec) => {
@@ -119,21 +119,21 @@ MyBachecaSchema.statics.findAllIdApp = async function(idapp) {
};
MyBachecaSchema.statics.getFieldsForSearch = function() {
MyBachecaSchema.statics.getFieldsForSearch = function () {
return [];
};
MyBachecaSchema.statics.getFieldsLastForSearch = function() {
MyBachecaSchema.statics.getFieldsLastForSearch = function () {
return [
{field: 'note', type: tools.FieldType.string},
{field: 'descr', type: tools.FieldType.string},
{field: 'recSkill.descr', type: tools.FieldType.string},
{field: 'MyBacheca.descr', type: tools.FieldType.string},
{ field: 'note', type: tools.FieldType.string },
{ field: 'descr', type: tools.FieldType.string },
{ field: 'recSkill.descr', type: tools.FieldType.string },
{ field: 'MyBacheca.descr', type: tools.FieldType.string },
];
};
MyBachecaSchema.statics.executeQueryTable = function(idapp, params, user) {
MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -167,6 +167,7 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params, user) {
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
@@ -177,12 +178,12 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params, user) {
},
};
params = {...params, ...otherparams};
params = { ...params, ...otherparams };
return tools.executeQueryTable(this, idapp, params, user);
};
MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
const MyBacheca = this;
const query = [
@@ -509,7 +510,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
});
};
MyBachecaSchema.statics.getCompleteRecord = function(idapp, id) {
MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
const MyBacheca = this;
return MyBacheca.getMyRecById(idapp, id);
@@ -519,4 +520,4 @@ MyBachecaSchema.statics.getCompleteRecord = function(idapp, id) {
const MyBacheca = mongoose.model('MyBacheca', MyBachecaSchema);
module.exports = {MyBacheca};
module.exports = { MyBacheca };

View File

@@ -167,6 +167,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,

View File

@@ -167,6 +167,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,

View File

@@ -168,6 +168,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,

View File

@@ -731,6 +731,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
}, {
name: 1,
surname: 1,
lasttimeonline: 1,
lang: 1,
username: 1,
'profile.notifs': 1,

File diff suppressed because it is too large Load Diff

View File

@@ -26,6 +26,7 @@ router.post('/load', async (req, res) => {
let datastat = {
num_reg: await User.getUsersRegistered(idapp),
num_reg_today: await User.getUsersRegisteredToday(idapp),
online_today: await User.getUsersOnLineToday(idapp),
// num_passeggeri: await 0,
// num_imbarcati: 0,
@@ -46,6 +47,7 @@ router.post('/load', async (req, res) => {
// imbarcati_weekly: 0,
reg_weekly: await User.calcRegWeekly(idapp),
lastsreg: await User.getLastUsers(idapp),
lastsonline: await User.getLastOnlineUsers(idapp),
checkuser: await User.checkUser(idapp, username),
// navi_partite: await Nave.getNaviPartite(idapp),
// navi_in_partenza: await Nave.getNaviInPartenza(idapp),