diff --git a/logtrans.txt b/logtrans.txt index 2c82c16..f8b62ee 100644 --- a/logtrans.txt +++ b/logtrans.txt @@ -514,4 +514,9 @@ Dom 23/11 ORE 01:10: [Circuito RIS Italia]: Inviate Monete da perseo9 a s Saldi: perseo9: -19.00 RIS] -surya1977: 141.95 RIS] \ No newline at end of file +surya1977: 141.95 RIS] +Gio 04/12 ORE 18:55: [Circuito RIS Bologna]: Inviate Monete da SurTest a ElenaEspx 0.1 RIS [causale: ] + +Saldi: +SurTest: 0.00 RIS] +ElenaEspx: 38.05 RIS] \ No newline at end of file diff --git a/src/models/bacheca.js b/src/models/bacheca.js new file mode 100755 index 0000000..528ef2a --- /dev/null +++ b/src/models/bacheca.js @@ -0,0 +1,88 @@ +const mongoose = require('mongoose').set('debug', false) +const Schema = mongoose.Schema; + +mongoose.Promise = global.Promise; +mongoose.level = "F"; + +const tools = require('../tools/general'); + +const { ObjectId } = require('mongodb'); + +// Resolving error Unknown modifier: $pushAll +mongoose.plugin(schema => { + schema.options.usePushEach = true +}); + +const BachecaSchema = new Schema({ + _id: { + type: Number, + }, + descr: { + type: String, + }, + idSectorBacheca: [{ + type: Number + }], + icon: { + type: String, + }, + img: { + type: String, + }, +}); + +BachecaSchema.statics.findAllIdApp = async function (idapp) { + const Bacheca = this; + + const query = [ + { $sort: { descr: 1 } } + ]; + + const res = await Bacheca + .aggregate(query) + .then((arrrec) => { + return arrrec + }) + + return res; + +}; + +BachecaSchema.pre('save', async function (next) { + if (this.isNew) { + const myrec = await Bacheca.findOne().limit(1).sort({_id:-1}); + if (!!myrec) { + if (myrec._doc._id === 0) + this._id = 1; + else + this._id = myrec._doc._id + 1; + + } else { + this._id = 1; + } + } + + next(); +}); + + + +BachecaSchema.statics.getFieldsForSearch = function () { + return [{ field: 'label', type: tools.FieldType.string }, + { field: 'descr', type: tools.FieldType.string }] +}; + +BachecaSchema.statics.executeQueryTable = function (idapp, params) { + params.fieldsearch = this.getFieldsForSearch(); + return tools.executeQueryTable(this, 0, params); +}; + + +const Bacheca = mongoose.model('Bacheca', BachecaSchema); + +Bacheca.createIndexes() + .then(() => { }) + .catch((err) => { throw err; }); + + +module.exports = { Bacheca }; diff --git a/src/models/circuit.js b/src/models/circuit.js index 845ee25..409a815 100755 --- a/src/models/circuit.js +++ b/src/models/circuit.js @@ -166,6 +166,7 @@ const CircuitSchema = new Schema({ }, date_created: { type: Date, + default: Date.now, }, date_updated: { type: Date, diff --git a/src/models/mybacheca.js b/src/models/mybacheca.js index 2dfae5c..fe2e027 100755 --- a/src/models/mybacheca.js +++ b/src/models/mybacheca.js @@ -33,13 +33,24 @@ const MyBachecaSchema = new Schema({ }, userId: { type: Schema.Types.ObjectId, ref: 'User' }, groupname: { type: String }, - idSector: { + idSectorBacheca: { type: Number, - }, - idSkill: { + }, + idBacheca: { type: Number, default: 0, }, + // ------------------ + idSector: { // VECCHIO + type: Number, + }, + + idSkill: { // VECCHIO + type: Number, + default: 0, + }, + + // ------------------ idStatusSkill: [ { type: Number, @@ -123,6 +134,7 @@ const MyBachecaSchema = new Schema({ }, date_created: { type: Date, + default: Date.now, }, date_updated: { type: Date, @@ -233,8 +245,8 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) { }, { $lookup: { - from: 'skills', - localField: 'idSkill', + from: 'bachecas', + localField: 'idBacheca', foreignField: '_id', as: 'recSkill', }, @@ -256,10 +268,10 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) { }, { $lookup: { - from: 'sectors', - localField: 'idSector', + from: 'sectorbachecas', + localField: 'idSectorBacheca', foreignField: '_id', - as: 'sector', + as: 'sectorBacheca', }, }, { @@ -267,7 +279,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) { newRoot: { $mergeObjects: [ { - $arrayElemAt: ['$sector', 0], + $arrayElemAt: ['$sectorBacheca', 0], }, '$$ROOT', ], diff --git a/src/models/mygood.js b/src/models/mygood.js index ac55cbf..ebc8b8a 100755 --- a/src/models/mygood.js +++ b/src/models/mygood.js @@ -16,7 +16,7 @@ const { ObjectId } = require('mongodb'); const tableModel = shared_consts.TABLES_MYGOODS; // Resolving error Unknown modifier: $pushAll -mongoose.plugin(schema => { +mongoose.plugin((schema) => { schema.options.usePushEach = true; }); @@ -41,18 +41,21 @@ const MyGoodSchema = new Schema({ idShipping: [ { type: Number, - }], + }, + ], idContribType: [ { type: String, - }], + }, + ], idCity: [ { type: Number, - }], + }, + ], pub_to_share: { - type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW + type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW }, numLevel: { type: Number, @@ -61,9 +64,11 @@ const MyGoodSchema = new Schema({ adType: { type: Number, }, - otherfilters: [{ - type: Number, - }], + otherfilters: [ + { + type: Number, + }, + ], photos: [ { imagefile: { @@ -75,7 +80,8 @@ const MyGoodSchema = new Schema({ description: { type: String, }, - }], + }, + ], note: { type: String, default: '', @@ -89,19 +95,19 @@ const MyGoodSchema = new Schema({ }, date_created: { type: Date, + default: Date.now, }, date_updated: { type: Date, }, - }, + }, ...Reaction.getFieldsForReactions(), - ...tools.getFieldsForAnnunci() + ...tools.getFieldsForAnnunci(), }); MyGoodSchema.pre('save', async function (next) { if (this.isNew) { - if (!this.date_created) - this.date_created = new Date(); + if (!this.date_created) this.date_created = new Date(); } next(); @@ -110,15 +116,11 @@ MyGoodSchema.pre('save', async function (next) { MyGoodSchema.statics.findAllIdApp = async function (idapp) { const MyGood = this; - const query = [ - { $match: { idapp } }, - { $sort: { descr: 1 } }, - ]; + const query = [{ $match: { idapp } }, { $sort: { descr: 1 } }]; return await MyGood.aggregate(query).then((arrrec) => { return arrrec; }); - }; MyGoodSchema.statics.getFieldsForSearch = function () { @@ -134,7 +136,6 @@ MyGoodSchema.statics.getFieldsLastForSearch = function () { ]; }; - MyGoodSchema.statics.executeQueryTable = function (idapp, params, user) { params.fieldsearch = this.getFieldsForSearch(); params.fieldsearch_last = this.getFieldsLastForSearch(); @@ -159,44 +160,40 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) { const MyGood = this; let myparsid = { - '_id': idGood, + _id: idGood, idapp, }; let query = [ { - '$match': - myparsid, + $match: myparsid, }, { - '$sort': { - 'desc': 1, + $sort: { + desc: 1, }, }, { - '$addFields': { - 'myId1': { - '$toObjectId': '$userId', + $addFields: { + myId1: { + $toObjectId: '$userId', }, }, }, { - '$lookup': { - 'from': 'users', - 'localField': 'myId1', - 'foreignField': '_id', - 'as': 'user', + $lookup: { + from: 'users', + localField: 'myId1', + foreignField: '_id', + as: 'user', }, }, { - '$replaceRoot': { - 'newRoot': { - '$mergeObjects': [ + $replaceRoot: { + newRoot: { + $mergeObjects: [ { - '$arrayElemAt': [ - '$user', - 0, - ], + $arrayElemAt: ['$user', 0], }, '$$ROOT', ], @@ -207,22 +204,19 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) { $project: shared_consts.getProjectForAll({}, tableModel), }, { - '$lookup': { - 'from': 'goods', - 'localField': 'idGood', - 'foreignField': '_id', - 'as': 'recGood', + $lookup: { + from: 'goods', + localField: 'idGood', + foreignField: '_id', + as: 'recGood', }, }, { - '$replaceRoot': { - 'newRoot': { - '$mergeObjects': [ + $replaceRoot: { + newRoot: { + $mergeObjects: [ { - '$arrayElemAt': [ - '$recGood', - 0, - ], + $arrayElemAt: ['$recGood', 0], }, '$$ROOT', ], @@ -233,23 +227,19 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) { $project: shared_consts.getProjectForAll({}, tableModel), }, { - '$lookup': { - 'from': 'sectorgoods', - 'localField': 'idSectorGood', - // 'localField': 'recGood.idSectorGood', - 'foreignField': '_id', - 'as': 'sectorGood', + $lookup: { + from: 'sectorgoods', + localField: 'idSectorGood', + foreignField: '_id', + as: 'sectorGood', }, }, { - '$replaceRoot': { - 'newRoot': { - '$mergeObjects': [ + $replaceRoot: { + newRoot: { + $mergeObjects: [ { - '$arrayElemAt': [ - '$sectorgood', - 0, - ], + $arrayElemAt: ['$sectorgood', 0], }, '$$ROOT', ], @@ -258,10 +248,10 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) { }, { $lookup: { - 'from': 'mygroups', - 'localField': 'groupname', - 'foreignField': 'groupname', - 'as': 'mygrp', + from: 'mygroups', + localField: 'groupname', + foreignField: 'groupname', + as: 'mygrp', }, }, { @@ -274,22 +264,19 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) { $project: shared_consts.getProjectForAll({}, tableModel), }, { - '$lookup': { - 'from': 'subgoods', - 'localField': 'idShipping', - 'foreignField': '_id', - 'as': 'MyGood', + $lookup: { + from: 'subgoods', + localField: 'idShipping', + foreignField: '_id', + as: 'MyGood', }, }, { - '$replaceRoot': { - 'newRoot': { - '$mergeObjects': [ + $replaceRoot: { + newRoot: { + $mergeObjects: [ { - '$arrayElemAt': [ - '$MyGood', - 0, - ], + $arrayElemAt: ['$MyGood', 0], }, '$$ROOT', ], @@ -300,22 +287,19 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) { $project: shared_consts.getProjectForAll({}, tableModel), }, { - '$lookup': { - 'from': 'cities', - 'localField': 'idCity', - 'foreignField': '_id', - 'as': 'mycities', + $lookup: { + from: 'cities', + localField: 'idCity', + foreignField: '_id', + as: 'mycities', }, }, { - '$replaceRoot': { - 'newRoot': { - '$mergeObjects': [ + $replaceRoot: { + newRoot: { + $mergeObjects: [ { - '$arrayElemAt': [ - '$mycities', - 0, - ], + $arrayElemAt: ['$mycities', 0], }, '$$ROOT', ], @@ -344,32 +328,30 @@ MyGoodSchema.statics.getCompleteRecord = function (idapp, id) { const MyGood = this; return MyGood.getMyRecById(idapp, id); - }; MyGoodSchema.statics.getProject = function () { let proj = { - 'recGood': 1, - 'sectorGood': 1, - 'idSectorGood': 1, - 'idGood': 1, - 'idShipping': 1, - 'idStatusGood': 1, + recGood: 1, + sectorGood: 1, + idSectorGood: 1, + idGood: 1, + idShipping: 1, + idStatusGood: 1, //**ADDFIELD_MYGOOD - }; - const proj_add = shared_consts.getProjectForAll() + const proj_add = shared_consts.getProjectForAll(); return Object.assign({}, proj, proj_add); - -} +}; const MyGood = mongoose.model('MyGood', MyGoodSchema); MyGood.createIndexes() - .then(() => { }) - .catch((err) => { throw err; }); - + .then(() => {}) + .catch((err) => { + throw err; + }); module.exports = { MyGood }; diff --git a/src/models/mygroup.js b/src/models/mygroup.js index 7e3af8f..5972067 100755 --- a/src/models/mygroup.js +++ b/src/models/mygroup.js @@ -96,6 +96,7 @@ const MyGroupSchema = new Schema({ }, date_created: { type: Date, + default: Date.now, }, date_updated: { type: Date, diff --git a/src/models/myhosp.js b/src/models/myhosp.js index 9488d3c..123a5d6 100755 --- a/src/models/myhosp.js +++ b/src/models/myhosp.js @@ -96,6 +96,7 @@ const MyHospSchema = new Schema({ }, date_created: { type: Date, + default: Date.now, }, date_updated: { type: Date, @@ -359,7 +360,7 @@ MyHospSchema.statics.SettaAdTypeOffro_In_Hosps = async function () { } }; -MyHospSchema.statics.getProject = function () { +/*MyHospSchema.statics.getProject = function () { let proj = { visibile: 1, typeHosp: 1, @@ -378,7 +379,7 @@ MyHospSchema.statics.getProject = function () { return Object.assign({}, proj, proj_add); } - +*/ const MyHosp = mongoose.model('MyHosp', MyHospSchema); diff --git a/src/models/myskill.js b/src/models/myskill.js index 62935b7..3dfd65f 100755 --- a/src/models/myskill.js +++ b/src/models/myskill.js @@ -96,6 +96,7 @@ const MySkillSchema = new Schema( }, date_created: { type: Date, + default: Date.now, }, date_updated: { type: Date, @@ -347,7 +348,7 @@ MySkillSchema.statics.getMyRecById = function (idapp, idSkill) { }); }; -MySkillSchema.statics.getProject = function (proj_add2) { +/*MySkillSchema.statics.getProject = function (proj_add2) { let proj = { recSkill: 1, sector: 1, @@ -364,6 +365,7 @@ MySkillSchema.statics.getProject = function (proj_add2) { return Object.assign({}, proj, proj_add); } + */ MySkillSchema.statics.getCompleteRecord = function (idapp, id) { const MySkill = this; diff --git a/src/models/sectorbacheca.js b/src/models/sectorbacheca.js new file mode 100755 index 0000000..51e24e8 --- /dev/null +++ b/src/models/sectorbacheca.js @@ -0,0 +1,88 @@ +const mongoose = require('mongoose').set('debug', false) +const Schema = mongoose.Schema; + +mongoose.Promise = global.Promise; +mongoose.level = "F"; + +const tools = require('../tools/general'); + +const { ObjectId } = require('mongodb'); + +// Resolving error Unknown modifier: $pushAll +mongoose.plugin(schema => { + schema.options.usePushEach = true +}); + +const SectorBachecaSchema = new Schema({ + _id: { + type: Number, + }, + descr: { + type: String, + }, + idSectorBacheca: { + type: Number + }, + icon: { + type: String, + }, + img: { + type: String, + }, + color: { + type: String, + }, + theme: { + type: String, + }, +}); + +SectorBachecaSchema.pre('save', async function (next) { + if (this.isNew) { + const myrec = await SectorBacheca.findOne().limit(1).sort({_id:-1}); + if (!!myrec) { + if (myrec._doc._id === 0) + this._id = 1; + else + this._id = myrec._doc._id + 1; + } else { + this._id = 1; + } + } + + next(); +}); + +SectorBachecaSchema.statics.findAllIdApp = async function (idapp) { + const SectorBacheca = this; + + const query = [ + { $sort: { descr: 1 } } + ]; + + return await SectorBacheca + .aggregate(query) + .then((arrrec) => { + return arrrec + }) + +}; + +SectorBachecaSchema.statics.getFieldsForSearch = function () { + return [{ field: 'descr', type: tools.FieldType.string }] +}; + +SectorBachecaSchema.statics.executeQueryTable = function (idapp, params) { + params.fieldsearch = this.getFieldsForSearch(); + return tools.executeQueryTable(this, 0, params); +}; + + +const SectorBacheca = mongoose.model('SectorBacheca', SectorBachecaSchema); + +SectorBacheca.createIndexes() + .then(() => { }) + .catch((err) => { throw err; }); + + +module.exports = { SectorBacheca }; diff --git a/src/models/sendnotif.js b/src/models/sendnotif.js index 817e5bb..cafe64c 100755 --- a/src/models/sendnotif.js +++ b/src/models/sendnotif.js @@ -1383,6 +1383,8 @@ sendNotifSchema.statics.getNotificationRecipients = async function (myrecnotifpa if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) { idSector = myrectableorig.idSectorGood; + } else if (myrecnotifpass.tablerec === shared_consts.TABLES_MYBACHECAS) { + idSector = myrectableorig.idSectorBacheca; } else { idSector = myrectableorig.idSector; } diff --git a/src/models/version.js b/src/models/version.js new file mode 100755 index 0000000..02e2507 --- /dev/null +++ b/src/models/version.js @@ -0,0 +1,163 @@ +const mongoose = require('mongoose').set('debug', false); +const Schema = mongoose.Schema; + +mongoose.Promise = global.Promise; +mongoose.level = 'F'; + +const tools = require('../tools/general'); + +const { ObjectId } = require('mongodb'); + +const LASTVERSION = 'lastversion'; + +// Resolving error Unknown modifier: $pushAll +mongoose.plugin((schema) => { + schema.options.usePushEach = true; +}); + +const VersionSchema = new Schema({ + descr: { + type: String, + }, + idapp: { + type: String, + }, + executed: { + type: Boolean, + }, + table: { + type: String, + }, + version: { + type: Number, + }, + date_created: { + type: Date, + }, +}); + +VersionSchema.statics.isJobExecuted = async function (idapp, descr) { + const Version = this; + + try { + const myrec = await Version.findOne({ idapp, descr }); + return myrec.executed; + } catch (e) { + return false; + } +}; + +VersionSchema.statics.setJobExecuted = async function (idapp, descr) { + const Version = this; + + try { + const myrec = await Version.findOneAndUpdate( + { idapp, descr }, + { + $setOnInsert: { idapp, descr }, + $set: { executed: true }, + }, + { new: true, upsert: true } + ); + + if (!myrec) { + throw new Error(`Error setting job as executed for idapp ${idapp} and descr ${descr}`); + } + + return myrec.executed; + } catch (e) { + console.error(`Error in setJobExecuted: ${e.message}`); + return false; + } +}; + +VersionSchema.statics.findAllIdApp = async function (idapp) { + const Version = this; + + const query = [{ $sort: { descr: 1 } }]; + + const res = await Version.aggregate(query).then((arrrec) => { + return arrrec; + }); + + return res; +}; + +VersionSchema.statics.getLastVersionRun = async function (idapp) { + const Version = this; + + try { + const myrec = await Version.findOne({ idapp, table: '', descr: LASTVERSION }); + return myrec ? myrec.version : 0; + } catch (e) { + return 0; + } +}; + +VersionSchema.statics.setLastVersionRun = async function (idapp, version) { + const Version = this; + + try { + const myrec = await Version.findOneAndUpdate( + { idapp, table: '', descr: LASTVERSION }, + { + $setOnInsert: { idapp, table: '', descr: LASTVERSION }, + $set: { version }, + }, + { new: true, upsert: true } + ); + + return !!myrec; + } catch (e) { + console.error(`Error in setLastVersionTable: ${e.message}`); + return false; + } +}; + + + + +VersionSchema.statics.isTableVersionUpdated = async function (idapp, table) { + const Version = this; + + const lastversion = await Version.getLastVersionRun(idapp); + + try { + const myrec = await Version.findOne({ idapp, table }); + return myrec.version === lastversion; + } catch (e) { + return false; + } +}; + +VersionSchema.statics.updateTableVersion = async function (idapp, table, version) { + const Version = this; + + try { + const myrec = await Version.findOneAndUpdate( + { idapp, table }, + { + $setOnInsert: { idapp, table }, + $set: { version }, + }, + { new: true, upsert: true } + ); + + return !!myrec; + } catch (e) { + console.error(`Error in updateTableVersion: ${e.message}`); + return false; + } +}; + + + +const Version = mongoose.model('Version', VersionSchema); + +Version.createIndexes() + .then(() => {}) + .catch((err) => { + throw err; + }); + +module.exports = { Version }; diff --git a/src/populate/OLD_goods.js b/src/populate/OLD_goods.js new file mode 100644 index 0000000..0c71e83 --- /dev/null +++ b/src/populate/OLD_goods.js @@ -0,0 +1,82 @@ +module.exports = { + list: [ + { _id: 1, idSectorGood: [1], descr: 'Abbigliamento donna', icon: 'fas fa-tshirt' }, + { _id: 2, idSectorGood: [1], descr: 'Abbigliamento uomo', icon: 'fas fa-tshirt' }, + { _id: 3, idSectorGood: [1], descr: 'Accessori', icon: 'fas fa-glasses' }, + { _id: 4, idSectorGood: [1], descr: 'Scarpe donna', icon: 'fas fa-shoe-prints' }, + { _id: 5, idSectorGood: [1], descr: 'Scarpe uomo', icon: 'fas fa-shoe-prints' }, + { _id: 6, idSectorGood: [2], descr: 'Bagno', icon: 'fas fa-bath' }, + { _id: 7, idSectorGood: [2], descr: 'Camera', icon: 'fas fa-bed' }, + { _id: 8, idSectorGood: [2], descr: "Complementi d'arredo", icon: 'fas fa-couch' }, + { _id: 9, idSectorGood: [2], descr: 'Cucina', icon: 'fas fa-utensils' }, + { _id: 10, idSectorGood: [2], descr: 'Esterno', icon: 'fas fa-tree' }, + { _id: 11, idSectorGood: [2], descr: 'Soggiorno', icon: 'fas fa-tv' }, + { _id: 12, idSectorGood: [3], descr: 'Altri veicoli', icon: 'fas fa-car' }, + { _id: 13, idSectorGood: [3], descr: 'Auto', icon: 'fas fa-car' }, + { _id: 14, idSectorGood: [3], descr: 'Moto', icon: 'fas fa-motorcycle' }, + { _id: 15, idSectorGood: [3], descr: 'Camper', icon: 'fas fa-caravan' }, + { _id: 16, idSectorGood: [3], descr: 'Van (furgoni camperizzati)', icon: 'fas fa-truck' }, + { _id: 17, idSectorGood: [4], descr: 'Bigiotteria', icon: 'fas fa-gem' }, + { _id: 18, idSectorGood: [4], descr: 'Lavoretti', icon: 'fas fa-paint-brush' }, + { _id: 19, idSectorGood: [4], descr: 'Altro', icon: 'fas fa-question' }, + { _id: 20, idSectorGood: [5], descr: 'Accessori bellezza', icon: 'fas fa-spa' }, + { _id: 21, idSectorGood: [5], descr: 'Creme e detergenti', icon: 'fas fa-pump-soap' }, + { _id: 22, idSectorGood: [5], descr: 'Trucchi e profumi', icon: 'fas fa-palette' }, + { _id: 23, idSectorGood: [6], descr: 'Giocattoli e giochi di società', icon: 'fas fa-dice' }, + { _id: 24, idSectorGood: [6], descr: 'Igiene e pannolini', icon: 'fas fa-baby' }, + { _id: 25, idSectorGood: [6], descr: 'Lettini e culle', icon: 'fas fa-baby-carriage' }, + { _id: 26, idSectorGood: [6], descr: 'Passeggini & co', icon: 'fas fa-baby-carriage' }, + { _id: 27, idSectorGood: [6], descr: 'Vestiti e scarpe', icon: 'fas fa-socks' }, + { _id: 28, idSectorGood: [7], descr: 'Bere', icon: 'fas fa-glass-cheers' }, + { _id: 29, idSectorGood: [7], descr: 'Mangiare', icon: 'fas fa-utensils' }, + { _id: 30, idSectorGood: [8], descr: 'Antiquariato', icon: 'fas fa-history' }, + { _id: 31, idSectorGood: [8], descr: 'Collezionismo', icon: 'fas fa-coins' }, + { _id: 32, idSectorGood: [9], descr: 'Cellulari e accessori', icon: 'fas fa-mobile-alt' }, + { _id: 33, idSectorGood: [9], descr: 'Computer e software', icon: 'fas fa-laptop' }, + { _id: 34, idSectorGood: [9], descr: 'Elettrodomestici', icon: 'fas fa-blender' }, + { _id: 35, idSectorGood: [9], descr: 'Fotografia', icon: 'fas fa-camera' }, + { _id: 36, idSectorGood: [9], descr: 'Videogiochi e console', icon: 'fas fa-gamepad' }, + { _id: 37, idSectorGood: [10], descr: 'Console', icon: 'fas fa-gamepad' }, + { _id: 38, idSectorGood: [10], descr: 'Giochi di società', icon: 'fas fa-dice' }, + { _id: 39, idSectorGood: [10], descr: 'PC games', icon: 'fas fa-desktop' }, + { _id: 40, idSectorGood: [11], descr: 'Attrezzatura', icon: 'fas fa-tools' }, + { _id: 41, idSectorGood: [11], descr: 'Materiali', icon: 'fas fa-box-open' }, + { _id: 42, idSectorGood: [11], descr: 'Prodotti', icon: 'fas fa-box' }, + { _id: 43, idSectorGood: [11], descr: 'Strumentazione', icon: 'fas fa-toolbox' }, + { _id: 44, idSectorGood: [12], descr: ' riviste e fumetti', icon: 'fas fa-book-open' }, + { _id: 45, idSectorGood: [13], descr: 'CD e vinili', icon: 'fas fa-compact-disc' }, + { _id: 46, idSectorGood: [13], descr: 'Film e DVD', icon: 'fas fa-film' }, + { _id: 47, idSectorGood: [13], descr: 'Strumenti musicali', icon: 'fas fa-guitar' }, + { _id: 48, idSectorGood: [14], descr: 'Arredamento', icon: 'fas fa-couch' }, + { _id: 49, idSectorGood: [14], descr: 'Attrezzature e accessori', icon: 'fas fa-tools' }, + { _id: 50, idSectorGood: [14], descr: 'Cancelleria e cartucce', icon: 'fas fa-print' }, + { _id: 51, idSectorGood: [15], descr: 'Abbigliamento', icon: 'fas fa-tshirt' }, + { _id: 52, idSectorGood: [15], descr: 'Attrezzature e accessori Sport', icon: 'fas fa-football-ball' }, + { _id: 53, idSectorGood: [15], descr: 'Bici e accessori', icon: 'fas fa-bicycle' }, + { _id: 54, idSectorGood: [17], descr: 'Edilizia', icon: 'fas fa-hard-hat' }, + { _id: 55, idSectorGood: [17], descr: 'Modellismo', icon: 'fas fa-puzzle-piece' }, + { _id: 56, idSectorGood: [17], descr: 'Cucito', icon: 'fas fa-cut' }, + { _id: 57, idSectorGood: [17], descr: 'Pulizia', icon: 'fas fa-broom' }, + { _id: 58, idSectorGood: [17], descr: 'Per Imbiancare', icon: 'fas fa-paint-roller' }, + { _id: 59, idSectorGood: [17], descr: 'Giardinaggio', icon: 'fas fa-seedling' }, + { _id: 60, idSectorGood: [17], descr: 'Falegnameria', icon: 'fas fa-hammer' }, + { _id: 61, idSectorGood: [7], descr: 'Pane', icon: 'fas fa-bread-slice' }, + { _id: 62, idSectorGood: [7], descr: 'Pasta', icon: 'fas fa-utensils' }, + { _id: 63, idSectorGood: [7], descr: 'Formaggi', icon: 'fas fa-cheese' }, + { _id: 64, idSectorGood: [7], descr: 'Olio', icon: 'fas fa-oil-can' }, + { _id: 65, idSectorGood: [7], descr: 'Fervida', icon: 'fas fa-fire' }, + { _id: 66, idSectorGood: [7], descr: 'Fermentati', icon: 'fas fa-beer' }, + { _id: 67, idSectorGood: [7], descr: 'Marmellate', icon: 'fas fa-jar' }, + { _id: 68, idSectorGood: [7], descr: 'Salse', icon: 'fas fa-mortar-pestle' }, + { _id: 69, idSectorGood: [20], descr: 'Cereali', icon: 'fas fa-wheat' }, + { _id: 70, idSectorGood: [20], descr: 'Frutta', icon: 'fas fa-apple-alt' }, + { _id: 71, idSectorGood: [20], descr: 'Ortaggi', icon: 'fas fa-carrot' }, + { _id: 72, idSectorGood: [20], descr: 'Zootecnia', icon: 'fas fa-paw' }, + { _id: 73, idSectorGood: [20], descr: 'Biologica', icon: 'fas fa-leaf' }, + { _id: 74, idSectorGood: [20], descr: 'Permacultura', icon: 'fas fa-recycle' }, + { _id: 75, idSectorGood: [20], descr: 'Sinergico', icon: 'fas fa-handshake' }, + { _id: 76, idSectorGood: [20], descr: 'Tradizionale', icon: 'fas fa-tractor' }, + { _id: 77, idSectorGood: [20], descr: 'Viticoltura', icon: 'fas fa-wine-glass-alt' }, + { _id: 78, idSectorGood: [20], descr: 'Acquacoltura', icon: 'fas fa-fish' }, + ], +}; diff --git a/src/populate/sectorgoods.js b/src/populate/OLD_sectorgoods.js similarity index 100% rename from src/populate/sectorgoods.js rename to src/populate/OLD_sectorgoods.js diff --git a/src/populate/OLD_sectors.js b/src/populate/OLD_sectors.js new file mode 100644 index 0000000..907cdd6 --- /dev/null +++ b/src/populate/OLD_sectors.js @@ -0,0 +1,17 @@ +module.exports = { + list: [ + {_id: 1, descr: 'Abitare'}, + {_id: 2, descr: 'Agricoltura'}, + {_id: 3, descr: 'Alimentazione'}, + {_id: 4, descr: 'Animali'}, + {_id: 5, descr: 'Auto e Veicoli'}, + {_id: 6, descr: 'Benessere'},- + {_id: 7, descr: 'Per la Casa'}, + {_id: 8, descr: 'Intrattenimento'}, + {_id: 10, descr: 'Per la Persona'}, + {_id: 11, descr: 'Progetti di Gruppo'}, + {_id: 12, descr: 'Salute'}, + {_id: 13, descr: 'Tecnologie'}, + {_id: 14, descr: 'Servizi'}, + ], +}; \ No newline at end of file diff --git a/src/populate/skills.js b/src/populate/OLD_skills.js similarity index 100% rename from src/populate/skills.js rename to src/populate/OLD_skills.js diff --git a/src/populate/catalogs.js b/src/populate/catalogs.js deleted file mode 100644 index bc15e22..0000000 --- a/src/populate/catalogs.js +++ /dev/null @@ -1,26 +0,0 @@ -const { ObjectId } = require('mongodb'); - -module.exports = { - list: [ - /*{ _id: new ObjectId('605c72e2f9b1a019c1e4f4a1'), idapp: '18', title: 'Alimentazione Sana' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4a2'), idapp: '18', title: 'Attualità e Informazione Libera' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4a3'), idapp: '18', title: 'Psicologia e Crescita Personale' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4a4'), idapp: '18', title: 'Educazione e Formazione' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4a5'), idapp: '18', title: 'Bambini e Ragazzi Felici' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4a6'), idapp: '18', title: 'Salute e Benessere Naturali' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4a7'), idapp: '18', title: 'Nuove Scienze' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4a8'), idapp: '18', title: 'Spiritualità e Sciamanesimo' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4a9'), idapp: '18', title: 'Storia e Archeologia Segreta' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4aa'), idapp: '18', title: 'Autosufficienza, Autoproduzione e Vita Naturale' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4ab'), idapp: '18', title: 'Yoga' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4ac'), idapp: '18', title: 'Amici Animali' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4ad'), idapp: '18', title: 'Corpi Energetici' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4ae'), idapp: '18', title: 'Erbe, Alberi e Natura' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4af'), idapp: '18', title: 'Astrologia, Esoterismi e Numerologia' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4b0'), idapp: '18', title: 'Universo Femminile' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4b1'), idapp: '18', title: 'Sessualità e Relazione di coppia' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4b2'), idapp: '18', title: 'Tarocchi, Oracoli e Carte' }, - { _id: new ObjectId('605c72e2f9b1a019c1e4f4b3'), idapp: '18', title: 'Techiche per il corpo' }, - */ - ], -}; \ No newline at end of file diff --git a/src/populate/migration-categories.js b/src/populate/migration-categories.js new file mode 100644 index 0000000..36b6081 --- /dev/null +++ b/src/populate/migration-categories.js @@ -0,0 +1,528 @@ +// migration-categories.js + +const mongoose = require('mongoose'); + +const shared_consts = require('../tools/shared_nodejs'); +const tools = require('../tools/general'); + +const { Sector } = require('../models/sector'); +const { SectorGood } = require('../models/sectorgood'); +const { SectorBacheca } = require('../models/sectorbacheca'); +const { Skill } = require('../models/skill'); +const { Good } = require('../models/good'); +const { Bacheca } = require('../models/bacheca'); +const { Version } = require('../models/version'); + +const { MySkill } = require('../models/myskill'); +const { MyGood } = require('../models/mygood'); +const { MyBacheca } = require('../models/mybacheca'); + +// ============================================================================ +// MAPPING DEFINITIONS +// ============================================================================ + +// Mapping vecchi ID Skills -> nuovi ID Skills +const skillSectorMapping = { + 1: 1, // Abitare -> Abitare e Costruire + 2: 2, // Agricoltura -> Agricoltura e Orticoltura + 3: 3, // Alimentazione -> Alimentazione e Trasformazione + 4: 4, // Animali -> Animali e Allevamento + 5: 10, // Auto e Veicoli -> Mobilità e Trasporti + 6: 6, // Benessere -> Benessere e Cura Naturale + 7: 9, // Per la Casa -> Manutenzione e Riparazione + 8: 15, // Intrattenimento -> Tempo Libero e Cultura + 10: 7, // Per la Persona -> Educazione e Formazione (parte) + 11: 11, // Progetti di Gruppo -> Progetti Comunitari + 12: 12, // Salute -> Salute e Terapie + 13: 13, // Tecnologie -> Tecnologie Appropriate + 14: 5, // Servizi -> Artigianato e Creazione +}; + +// Mapping vecchi ID SubSkills -> nuovi ID SubSkills +const subSkillMapping = { + 1: 1, // Autocostruzione + 2: 4, // Ecovillaggi / Comunità + 3: 3, // Cohousing + 4: 13, // Orto sinergico + 5: 15, // Pacciamatura + 6: 14, // Orto tradizionale + 7: 16, // Permacultura + 8: 12, // Cultura idroponica + 9: 11, // Elettrocultura + 10: 10, // Aratura + semina + 11: 17, // Potatura + 12: 18, // Raccolta + 13: 20, // Preparazione cibi + 14: 21, // Preparazione bevande + 15: 20, // Autoproduzione alimenti e bevande + 16: 32, // Servizi per Cani + 17: 32, // Servizi per Gatti + 18: 30, // Servizi per Animali da allevamento + 19: 33, // Veterinario + 20: 114, // Riparazioni Auto + 21: 115, // Riparazioni Moto + 22: 111, // Riparazioni Camper / Van + 23: 111, // Creazione di Van Camperizzati + 24: 112, // Noleggio veicoli + 25: 113, // Lavaggio auto + 26: 50, // Alimentazione Naturale + 27: 57, // Ginnastica + 28: 68, // Yoga + 29: 66, // Trattamenti Olistici + 30: 60, // Meditazione e mindfulness + 31: 65, // Trattamenti Energetici + 32: 67, // Trattamenti Sonori + 33: 51, // Arteterapia + 34: 63, // Teatroterapia + 35: 52, // Cantoterapia + 36: 65, // Trattamenti Luminosi + 37: 55, // Fitoterapia + 38: 58, // Kinesiologia + 39: 66, // Terapie Naturali + 40: 96, // Muratore + 41: 95, // Imbianchino + 42: 91, // Elettricista - TV + 43: 41, // Falegname + 44: 92, // Fabbro + 45: 90, // Arredamento + 46: 94, // Idraulico + 47: 93, // Giardiniere + 48: 86, // Canne fumarie e camini e stufe + 49: 82, // Pannelli solari + 50: 101, // Riparazioni varie + 51: 101, // Tuttofare + 52: 100, // Traslochi + 53: 97, // Piastrellista + 54: 98, // Pulizie + 55: 171, // Ballo + 56: 172, // Canto + 57: 176, // Musica + 58: 175, // Letteratura e poesia + 59: 178, // Teatro + 60: 174, // Fotografia + 61: 173, // Film making + 62: 177, // Sport + 63: 170, // Arte + 70: 163, // Parrucchiere -> Sartoria su Misura + 71: 66, // Estetista -> Trattamenti Olistici + 72: 136, // Omeopatia + 73: 137, // Assistenza anziani -> OSS + 76: 125, // Baby sitter -> Volontariato + 77: 163, // Sarto + 78: 160, // Autoproduzione prodotti persona + 79: 70, // Corsi e Formazione + 80: 125, // Supporto spesa + 81: 125, // Volontariato + 82: 123, // Gruppi di acquisto + 83: 120, // Banca del tempo + 84: 121, // Collabora con noi + 85: 122, // Eventi + 86: 124, // Laboratori + 87: 121, // Idee e suggerimenti + 88: 133, // Medico di base + 89: 142, // Specialista + 90: 139, // Pediatra + 91: 131, // Dentista + 92: 140, // Psicologo + 93: 141, // Psicoterapeuta + 94: 138, // Ostetrica + 95: 135, // Nutrizionista + 97: 130, // Counseling + 98: 151, // Assistenza PC / software + 99: 150, // Assistenza Cellulari + 100: 154, // Realizzazione Siti web + 101: 153, // Realizzazione App / Piattaforme + 102: 152, // Corsi d'Informatica + 103: 99, // Riparazione Elettrodomestici + 104: 132, // Infermiera + 105: 137, // OSS + 106: 125, // Badante + 107: 59, // Massaggi + 109: 130, // Supporto + 110: 130, // Consulenza + 111: 56, // Floriterapia + 112: 54, // Costellazioni Familiari + 113: 53, // Coach Motivazionale + 114: 64, // Tecniche Essene + 115: 62, // Riflessologia + 116: 61, // Naturopatia + 120: 170, // Grafica + 121: 154, // Web + 122: 2, // Progettazione -> Bioedilizia + 123: 134, // Medicina Naturale + 124: 5, // Casa in Vendita + 125: 6, // Casa in Affitto + 126: 8, // Terreno + 127: 7, // Stanza in affitto + 128: 7, // Stanza in condivisione + 129: 23, // Home Restaurant + 130: 82, // Pannelli Solari + 131: 84, // Pompe di calore + 132: 82, // Impianti Fotovoltaici + 133: 43, // Restauro + 134: 101, // Altro + 135: 82, // Pannelli Solari + 136: 152, // Corso di Podcasting : Corsi d'Informatica + 137: 69, // Biodanza + 74: 75, // Contabile/commercialista -> Consulenze Professionali + 75: 75, // Avvocato -> Consulenze Professionali + 108: 126, // Affrancamento -> Servizi alla Comunità + 117: 75, // Organizzazione Aziendale -> Consulenze Professionali + 118: 75, // Project Manager -> Consulenze Professionali + 119: 75, // Consulenze per Startup -> Consulenze Professionali +}; + +// Mapping vecchi ID SectorGoods -> nuovi ID SectorGoods +const sectorGoodMapping = { + 1: 1, // Abbigliamento -> Abbigliamento e Accessori + 2: 2, // Arredamento -> Arredamento e Casa + 3: 3, // Auto e Moto -> Auto, Moto e Veicoli + 4: 4, // Artigianato -> Artigianato e Creazioni + 5: 5, // Bellezza e Igiene -> Bellezza e Cura Persona + 6: 6, // Bimbi -> Infanzia e Bambini + 7: 7, // Cibo -> Cibi e Bevande + 8: 8, // Collezionismo e Antiquariato (invariato) + 9: 9, // Elettronica -> Elettronica e Tecnologia + 10: 10, // Giochi -> Gaming e Console + 11: 11, // Hobby e Fai da Te -> Giardinaggio e Fai da Te + 12: 12, // Libri -> Libri e Riviste + 13: 13, // Musica e Film (invariato) + 14: 14, // Scuola e Ufficio (invariato) + 15: 15, // Sport -> Sport e Fitness + 16: null, // Varie -> DISTRIBUITO (rimuovere, troppo generico) + 17: 17, // Attrezzature -> Attrezzature e Strumenti + 18: 16, // Animali + 19: 20, // Arte e Decorazioni + 20: 19, // Agricoltura -> Agricoltura e Orticoltura + 21: 18, // Elettrodomestici +}; + +// Mapping vecchi ID SectorBacheca -> nuovi ID SectorBacheca +const sectorBachecaMapping = { + 1: 1, // Abitare -> Abitare Alternativo + 2: 2, // Agricoltura -> Agricoltura e Permacultura + 3: 3, // Alimentazione -> Alimentazione Consapevole + 4: 4, // Animali -> Animali e Natura + 5: 11, // Auto e Veicoli -> Mobilità Sostenibile + 6: 5, // Benessere -> Benessere Olistico + 7: 10, // Per la Casa -> Lavoro e Autoproduzione + 8: 6, // Intrattenimento -> Cultura e Arte + 10: 8, // Per la Persona -> Educazione Alternativa + 11: 12, // Progetti di Gruppo -> Progetti Comunitari + 12: 13, // Salute -> Salute Naturale + 13: 14, // Tecnologie -> Tecnologie Appropriate + 14: 7, // Servizi -> Economia Solidale +}; + +// Mapping vecchi idSkill -> nuovi idBacheca +const bachecaMapping = { + 1: 1, // Autocostruzione + 2: 4, // Ecovillaggi / Comunità -> Ecovillaggi + 3: 3, // Cohousing + 4: 12, // Orto sinergico -> Permacultura + 7: 12, // Permacultura + 26: 40, // Alimentazione Naturale -> Cerchi di Condivisione + 27: 44, // Ginnastica -> Yoga e Movimento + 28: 44, // Yoga -> Yoga e Movimento + 29: 43, // Trattamenti Olistici -> Pratiche Energetiche + 30: 42, // Meditazione e mindfulness -> Meditazione + 55: 50, // Ballo + 56: 51, // Canto -> Cerchi di Canto + 57: 53, // Musica -> Concerti + 59: 55, // Teatro + 79: 73, // Corsi e Formazione -> Workshop e Corsi + 82: 24, // Gruppi di acquisto -> Gruppi Acquisto + 83: 60, // Banca del tempo -> Banca del Tempo + 84: 114, // Collabora con noi -> Nuove Iniziative + 85: 113, // Eventi -> Eventi Comunitari + 86: 71, // Laboratori -> Laboratori Bambini + 87: 111, // Idee e suggerimenti -> Brainstorming + // Aggiungi altri mapping secondo necessità + // Per gli altri usa categoria generica o 0 +}; + +// ============================================================================ +// MIGRATION FUNCTIONS +// ============================================================================ + +/** + * Aggiorna i settori Skills con nuove categorie + */ +async function updateSkillSectors(Sector) { + console.log('🔄 Aggiornamento Skill Sectors...'); + + const newSectors = require('./new_sectors'); + + await Sector.deleteMany({}); + const result = await Sector.insertMany(newSectors.list); + + console.log(`✅ ${result.length} Skill Sectors aggiornati`); +} + +/** + * Aggiorna le Skills con nuove sottocategorie + */ +async function updateSkills(Skill) { + console.log('🔄 Aggiornamento Sub-Skills...'); + + const newSkills = require('./new_subskills'); // Il file che hai creato sopra + + await Skill.deleteMany({}); + const result = await Skill.insertMany(newSkills.list); + + console.log(`✅ ${result.length} Sub-Skills aggiornate`); +} + +async function updateSectorGoods(Good) { + console.log('🔄 Aggiornamento SectorGoods...'); + + const newSectorGoods = require('./new_sectorgoods'); + + await SectorGood.deleteMany({}); + const result = await SectorGood.insertMany(newSectorGoods.list); + + console.log(`✅ ${result.length} SectorGood aggiornati`); +} +async function updateSectorBachecas(Bacheca) { + console.log('🔄 Aggiornamento SectorBachecas...'); + + const newSectorBachecas = require('./new_sectorbachecas'); + + await SectorBacheca.deleteMany({}); + const result = await SectorBacheca.insertMany(newSectorBachecas.list); + + console.log(`✅ ${result.length} SectorBacheca aggiornati`); +} + +/** + * Aggiorna i Goods (rimozione campo color) + */ +async function updateGoods(Good) { + console.log('🔄 Aggiornamento Goods...'); + + const newGoods = require('./new_goods'); + + await Good.deleteMany({}); + const result = await Good.insertMany(newGoods.list); + + console.log(`✅ ${result.length} Goods aggiornati`); +} +async function updateBachecas(Good) { + console.log('🔄 Aggiornamento Bachecas...'); + + const newBachecas = require('./new_bachecas'); + + await Bacheca.deleteMany({}); + const result = await Bacheca.insertMany(newBachecas.list); + + console.log(`✅ ${result.length} Bachecas aggiornati`); +} + +/** + * Migra i record MySkill + */ +async function migrateMySkills(MySkill) { + console.log('🔄 Migrazione MySkill records...'); + + const records = await MySkill.find({}).lean(); + let updated = 0; + let unchanged = 0; + + for (const record of records) { + const updates = {}; + + // Mappa idSector + if (record.idSector && skillSectorMapping[record.idSector]) { + if (skillSectorMapping[record.idSector] !== record.idSector) { + updates.idSector = skillSectorMapping[record.idSector]; + } + } + + // Mappa idSkill (tutte hanno destinazione ora) + if (record.idSkill && subSkillMapping[record.idSkill] !== undefined) { + const newId = subSkillMapping[record.idSkill]; + if (newId !== record.idSkill) { + updates.idSkill = newId; + } + } + + if (Object.keys(updates).length > 0) { + await MySkill.updateOne({ _id: record._id }, { $set: updates }); + updated++; + } else { + unchanged++; + } + } + + console.log(`✅ MySkill: ${updated} aggiornati, ${unchanged} invariati`); +} + +/** + * Migra i record MyGood + */ +async function migrateMyGoods(MyGood) { + console.log('🔄 Migrazione MyGood records...'); + + const records = await MyGood.find({}).lean(); + let updated = 0; + let unchanged = 0; + + for (const record of records) { + const updates = {}; + + // Mappa idSectorGood + if (record.idSectorGood && sectorGoodMapping[record.idSectorGood]) { + if (sectorGoodMapping[record.idSectorGood] !== record.idSectorGood) { + updates.idSectorGood = sectorGoodMapping[record.idSectorGood]; + } + } + + // idGood rimane invariato (stessi ID) + + if (Object.keys(updates).length > 0) { + await MyGood.updateOne({ _id: record._id }, { $set: updates }); + updated++; + } else { + unchanged++; + } + } + + console.log(`✅ MyGood: ${updated} aggiornati, ${unchanged} invariati`); +} + +/** + * Migra i record MyBacheca + */ +async function migrateMyBacheca(MyBacheca) { + console.log('🔄 Migrazione MyBacheca records...'); + + const records = await MyBacheca.find({}).lean(); + let updated = 0; + let unchanged = 0; + + for (const record of records) { + const updates = {}; + + // Mappa idSector -> idSectorBacheca (vecchio campo -> nuovo campo) + if (record.idSector && sectorBachecaMapping[record.idSector]) { + updates.idSectorBacheca = sectorBachecaMapping[record.idSector]; + } + + // Mappa idSkill -> idBacheca (vecchio campo -> nuovo campo) + if (record.idSkill && bachecaMapping[record.idSkill] !== undefined) { + updates.idBacheca = bachecaMapping[record.idSkill]; + } else if (record.idSkill) { + // Se non c'è mapping specifico, metti 0 (generico) + updates.idBacheca = 0; + } + + // Rimuovi i campi vecchi + const unsetFields = {}; + if (record.idSector !== undefined) unsetFields.idSector = ''; + if (record.idSkill !== undefined) unsetFields.idSkill = ''; + + if (Object.keys(updates).length > 0 || Object.keys(unsetFields).length > 0) { + const updateQuery = {}; + + if (Object.keys(updates).length > 0) { + updateQuery.$set = updates; + } + + if (Object.keys(unsetFields).length > 0) { + updateQuery.$unset = unsetFields; + } + + await MyBacheca.updateOne({ _id: record._id }, updateQuery); + updated++; + } else { + unchanged++; + } + } + + console.log(`✅ MyBacheca: ${updated} aggiornati, ${unchanged} invariati`); +} +// ============================================================================ +// MAIN MIGRATION SCRIPT +// ============================================================================ + +async function runMigration() { + try { + const idapp = 0; // TUTTI + + console.log('🚀 Controllo Versioni Tabelle (runMigration)'); + + const isMigratioDic2025Executed = await Version.isJobExecuted( + idapp, + shared_consts.JOB_TO_EXECUTE.MIGRATION_SECTORS_DIC25 + ); + + const vers_server_str = await tools.getVersServer(); + + const version_server = tools.versionToNumber(vers_server_str); + + // Step 1: Aggiorna categorie solo 1 volta sola ! + if (!isMigratioDic2025Executed) { + console.log('\n Migrazione DIC 2025 da ESEGUIRE ----------- '); + await updateSkillSectors(Sector); + await updateSkills(Skill); + await updateSectorGoods(SectorGood); + await updateSectorBachecas(SectorBacheca); + await updateGoods(Good); + await updateBachecas(Bacheca); + } + + const myskill_updated = await Version.isTableVersionUpdated(idapp, 'myskill'); + if (!myskill_updated) { + // MYSKILL + + if (!isMigratioDic2025Executed) await migrateMySkills(MySkill); + + // ++ Altri aggiornamenti da fare + + // FINE - Aggiorna Versione Tabella + await Version.updateTableVersion(idapp, 'myskill', version_server); + } + + const mygood_updated = await Version.isTableVersionUpdated(idapp, 'mygood'); + if (!mygood_updated) { + // MYGOOD + if (!isMigratioDic2025Executed) await migrateMyGoods(MyGood); + + // ++ Altri aggiornamenti da fare + + // FINE - Aggiorna Versione Tabella + await Version.updateTableVersion(idapp, 'mygood', version_server); + } + + const mybacheca_updated = await Version.isTableVersionUpdated(idapp, 'mybacheca'); + if (!mybacheca_updated) { + // MYBACHECA + + if (!isMigratioDic2025Executed) await migrateMyBacheca(MyBacheca); + + // ++ Altri aggiornamenti da fare + + // FINE - Aggiorna Versione Tabella + await Version.updateTableVersion(idapp, 'mybacheca', version_server); + } + + // FINE ----------------------- + if (!isMigratioDic2025Executed) { + await Version.setJobExecuted(idapp, shared_consts.JOB_TO_EXECUTE.MIGRATION_SECTORS_DIC25); + console.log('\n✅ Migrazione DIC 2025 completata con successo!'); + } + + await Version.setLastVersionRun(idapp, version_server); + } catch (error) { + console.error('❌ Errore durante la migrazione:', error); + } finally { + } +} + +module.exports = { + runMigration, + skillSectorMapping, + subSkillMapping, + sectorGoodMapping, + sectorBachecaMapping, +}; diff --git a/src/populate/new_bachecas.js b/src/populate/new_bachecas.js new file mode 100644 index 0000000..42ae069 --- /dev/null +++ b/src/populate/new_bachecas.js @@ -0,0 +1,99 @@ +// new_bachecas.js +module.exports = { + list: [ + // Abitare Alternativo (1) + { _id: 1, idSectorBacheca: [1], descr: 'Autocostruzione', icon: 'fas fa-hammer' }, + { _id: 2, idSectorBacheca: [1], descr: 'Bioedilizia', icon: 'fas fa-leaf' }, + { _id: 3, idSectorBacheca: [1], descr: 'Cohousing', icon: 'fas fa-home-heart' }, + { _id: 4, idSectorBacheca: [1], descr: 'Ecovillaggi', icon: 'fas fa-users' }, + { _id: 5, idSectorBacheca: [1], descr: 'Offerte Immobili', icon: 'fas fa-key' }, + { _id: 6, idSectorBacheca: [1], descr: 'Stanze Condivise', icon: 'fas fa-door-open' }, + + // Agricoltura e Permacultura (2) + { _id: 10, idSectorBacheca: [2], descr: 'Corsi Agricoltura', icon: 'fas fa-chalkboard-teacher' }, + { _id: 11, idSectorBacheca: [2], descr: 'Orti Condivisi', icon: 'fas fa-seedling' }, + { _id: 12, idSectorBacheca: [2], descr: 'Permacultura', icon: 'fas fa-recycle' }, + { _id: 13, idSectorBacheca: [2], descr: 'Scambio Sementi', icon: 'fas fa-exchange-alt' }, + { _id: 14, idSectorBacheca: [2], descr: 'Visite in Azienda', icon: 'fas fa-tractor' }, + { _id: 15, idSectorBacheca: [2], descr: 'Wwoof e Volontariato', icon: 'fas fa-hands-helping' }, + + // Alimentazione Consapevole (3) + { _id: 20, idSectorBacheca: [3], descr: 'Autoproduzione', icon: 'fas fa-jar' }, + { _id: 21, idSectorBacheca: [3], descr: 'Cene Condivise', icon: 'fas fa-utensils' }, + { _id: 22, idSectorBacheca: [3], descr: 'Corsi Cucina', icon: 'fas fa-cook' }, + { _id: 23, idSectorBacheca: [3], descr: 'Fermentazione', icon: 'fas fa-flask' }, + { _id: 24, idSectorBacheca: [3], descr: 'Gruppi Acquisto', icon: 'fas fa-shopping-basket' }, + { _id: 25, idSectorBacheca: [3], descr: 'Panificazione', icon: 'fas fa-bread-slice' }, + + // Animali e Natura (4) + { _id: 30, idSectorBacheca: [4], descr: 'Apicoltura', icon: 'fas fa-bee' }, + { _id: 31, idSectorBacheca: [4], descr: 'Escursioni Natura', icon: 'fas fa-hiking' }, + { _id: 32, idSectorBacheca: [4], descr: 'Pet Sitting Condiviso', icon: 'fas fa-paw' }, + { _id: 33, idSectorBacheca: [4], descr: 'Riconoscimento Piante', icon: 'fas fa-leaf' }, + + // Benessere Olistico (5) + { _id: 40, idSectorBacheca: [5], descr: 'Cerchi di Condivisione', icon: 'fas fa-circle' }, + { _id: 41, idSectorBacheca: [5], descr: 'Costellazioni Familiari', icon: 'fas fa-users' }, + { _id: 42, idSectorBacheca: [5], descr: 'Meditazione', icon: 'fas fa-om' }, + { _id: 43, idSectorBacheca: [5], descr: 'Pratiche Energetiche', icon: 'fas fa-hand-sparkles' }, + { _id: 44, idSectorBacheca: [5], descr: 'Yoga e Movimento', icon: 'fas fa-user-zen' }, + + // Cultura e Arte (6) + { _id: 50, idSectorBacheca: [6], descr: 'Ballo e Danza', icon: 'fas fa-music' }, + { _id: 51, idSectorBacheca: [6], descr: 'Cerchi di Canto', icon: 'fas fa-microphone' }, + { _id: 52, idSectorBacheca: [6], descr: 'Cinema e Film', icon: 'fas fa-film' }, + { _id: 53, idSectorBacheca: [6], descr: 'Concerti', icon: 'fas fa-guitar' }, + { _id: 54, idSectorBacheca: [6], descr: 'Mostre e Arte', icon: 'fas fa-palette' }, + { _id: 55, idSectorBacheca: [6], descr: 'Teatro', icon: 'fas fa-theater-masks' }, + + // Economia Solidale (7) + { _id: 60, idSectorBacheca: [7], descr: 'Banca del Tempo', icon: 'fas fa-clock' }, + { _id: 61, idSectorBacheca: [7], descr: 'Finanza Etica', icon: 'fas fa-piggy-bank' }, + { _id: 62, idSectorBacheca: [7], descr: 'Mercatini Scambio', icon: 'fas fa-store' }, + { _id: 63, idSectorBacheca: [7], descr: 'Monete Locali', icon: 'fas fa-coins' }, + + // Educazione Alternativa (8) + { _id: 70, idSectorBacheca: [8], descr: 'Educazione Parentale', icon: 'fas fa-child' }, + { _id: 71, idSectorBacheca: [8], descr: 'Laboratori Bambini', icon: 'fas fa-baby' }, + { _id: 72, idSectorBacheca: [8], descr: 'Scuola Libertaria', icon: 'fas fa-book-reader' }, + { _id: 73, idSectorBacheca: [8], descr: 'Workshop e Corsi', icon: 'fas fa-chalkboard-teacher' }, + + // Energie Rinnovabili (9) + { _id: 80, idSectorBacheca: [9], descr: 'Autocostruzione Solare', icon: 'fas fa-solar-panel' }, + { _id: 81, idSectorBacheca: [9], descr: 'Compostaggio', icon: 'fas fa-recycle' }, + { _id: 82, idSectorBacheca: [9], descr: 'Comunità Energetiche', icon: 'fas fa-plug' }, + { _id: 83, idSectorBacheca: [9], descr: 'Riciclo Creativo', icon: 'fas fa-trash-restore' }, + + // Lavoro e Autoproduzione (10) + { _id: 90, idSectorBacheca: [10], descr: 'Artigianato', icon: 'fas fa-hammer' }, + { _id: 91, idSectorBacheca: [10], descr: 'Autocostruzione', icon: 'fas fa-tools' }, + { _id: 92, idSectorBacheca: [10], descr: 'Falegnameria', icon: 'fas fa-saw' }, + { _id: 93, idSectorBacheca: [10], descr: 'Riparazione', icon: 'fas fa-wrench' }, + { _id: 94, idSectorBacheca: [10], descr: 'Sartoria', icon: 'fas fa-cut' }, + + // Mobilità Sostenibile (11) + { _id: 100, idSectorBacheca: [11], descr: 'Biciclette', icon: 'fas fa-bicycle' }, + { _id: 101, idSectorBacheca: [11], descr: 'Camperisti', icon: 'fas fa-caravan' }, + { _id: 102, idSectorBacheca: [11], descr: 'Car Pooling', icon: 'fas fa-car' }, + { _id: 103, idSectorBacheca: [11], descr: 'Ciclofficine', icon: 'fas fa-tools' }, + + // Progetti Comunitari (12) + { _id: 110, idSectorBacheca: [12], descr: 'Assemblee', icon: 'fas fa-users' }, + { _id: 111, idSectorBacheca: [12], descr: 'Brainstorming', icon: 'fas fa-lightbulb' }, + { _id: 112, idSectorBacheca: [12], descr: 'Co-progettazione', icon: 'fas fa-project-diagram' }, + { _id: 113, idSectorBacheca: [12], descr: 'Eventi Comunitari', icon: 'fas fa-calendar-alt' }, + { _id: 114, idSectorBacheca: [12], descr: 'Nuove Iniziative', icon: 'fas fa-rocket' }, + + // Salute Naturale (13) + { _id: 120, idSectorBacheca: [13], descr: 'Erboristeria', icon: 'fas fa-leaf' }, + { _id: 121, idSectorBacheca: [13], descr: 'Fitoterapia', icon: 'fas fa-mortar-pestle' }, + { _id: 122, idSectorBacheca: [13], descr: 'Medicine Tradizionali', icon: 'fas fa-hand-holding-medical' }, + { _id: 123, idSectorBacheca: [13], descr: 'Primo Soccorso', icon: 'fas fa-first-aid' }, + + // Tecnologie Appropriate (14) + { _id: 130, idSectorBacheca: [14], descr: 'Linux e Open Source', icon: 'fas fa-linux' }, + { _id: 131, idSectorBacheca: [14], descr: 'Privacy Digitale', icon: 'fas fa-shield-alt' }, + { _id: 132, idSectorBacheca: [14], descr: 'Riparazione Devices', icon: 'fas fa-mobile-alt' }, + { _id: 133, idSectorBacheca: [14], descr: 'Self Hosting', icon: 'fas fa-server' }, + ], +}; \ No newline at end of file diff --git a/src/populate/goods.js b/src/populate/new_goods.js similarity index 64% rename from src/populate/goods.js rename to src/populate/new_goods.js index 8f0f628..9a41654 100644 --- a/src/populate/goods.js +++ b/src/populate/new_goods.js @@ -1,82 +1,82 @@ module.exports = { list: [ - { _id: 1, idSectorGood: [1], descr: 'Abbigliamento donna', icon: 'fas fa-tshirt', color: 'pink' }, - { _id: 2, idSectorGood: [1], descr: 'Abbigliamento uomo', icon: 'fas fa-tshirt', color: 'blue' }, - { _id: 3, idSectorGood: [1], descr: 'Accessori', icon: 'fas fa-glasses', color: 'purple' }, - { _id: 4, idSectorGood: [1], descr: 'Scarpe donna', icon: 'fas fa-shoe-prints', color: 'pink' }, - { _id: 5, idSectorGood: [1], descr: 'Scarpe uomo', icon: 'fas fa-shoe-prints', color: 'blue' }, - { _id: 6, idSectorGood: [2], descr: 'Bagno', icon: 'fas fa-bath', color: 'teal' }, - { _id: 7, idSectorGood: [2], descr: 'Camera', icon: 'fas fa-bed', color: 'indigo' }, - { _id: 8, idSectorGood: [2], descr: 'Complementi d\'arredo', icon: 'fas fa-couch', color: 'brown' }, - { _id: 9, idSectorGood: [2], descr: 'Cucina', icon: 'fas fa-utensils', color: 'orange' }, - { _id: 10, idSectorGood: [2], descr: 'Esterno', icon: 'fas fa-tree', color: 'green' }, - { _id: 11, idSectorGood: [2], descr: 'Soggiorno', icon: 'fas fa-tv', color: 'grey' }, - { _id: 12, idSectorGood: [3], descr: 'Altri veicoli', icon: 'fas fa-car', color: 'black' }, - { _id: 13, idSectorGood: [3], descr: 'Auto', icon: 'fas fa-car', color: 'red' }, - { _id: 14, idSectorGood: [3], descr: 'Moto', icon: 'fas fa-motorcycle', color: 'black' }, - { _id: 15, idSectorGood: [3], descr: 'Camper', icon: 'fas fa-caravan', color: 'orange' }, - { _id: 16, idSectorGood: [3], descr: 'Van (furgoni camperizzati)', icon: 'fas fa-truck', color: 'blue' }, - { _id: 17, idSectorGood: [4], descr: 'Bigiotteria', icon: 'fas fa-gem', color: 'gold' }, - { _id: 18, idSectorGood: [4], descr: 'Lavoretti', icon: 'fas fa-paint-brush', color: 'yellow' }, - { _id: 19, idSectorGood: [4], descr: 'Altro', icon: 'fas fa-question', color: 'grey' }, - { _id: 20, idSectorGood: [5], descr: 'Accessori bellezza', icon: 'fas fa-spa', color: 'pink' }, - { _id: 21, idSectorGood: [5], descr: 'Creme e detergenti', icon: 'fas fa-pump-soap', color: 'teal' }, - { _id: 22, idSectorGood: [5], descr: 'Trucchi e profumi', icon: 'fas fa-palette', color: 'purple' }, - { _id: 23, idSectorGood: [6], descr: 'Giocattoli e giochi di società', icon: 'fas fa-dice', color: 'yellow' }, - { _id: 24, idSectorGood: [6], descr: 'Igiene e pannolini', icon: 'fas fa-baby', color: 'pink' }, - { _id: 25, idSectorGood: [6], descr: 'Lettini e culle', icon: 'fas fa-baby-carriage', color: 'blue' }, - { _id: 26, idSectorGood: [6], descr: 'Passeggini & co', icon: 'fas fa-baby-carriage', color: 'green' }, - { _id: 27, idSectorGood: [6], descr: 'Vestiti e scarpe', icon: 'fas fa-socks', color: 'purple' }, - { _id: 28, idSectorGood: [7], descr: 'Bere', icon: 'fas fa-glass-cheers', color: 'red' }, - { _id: 29, idSectorGood: [7], descr: 'Mangiare', icon: 'fas fa-utensils', color: 'orange' }, - { _id: 30, idSectorGood: [8], descr: 'Antiquariato', icon: 'fas fa-history', color: 'brown' }, - { _id: 31, idSectorGood: [8], descr: 'Collezionismo', icon: 'fas fa-coins', color: 'gold' }, - { _id: 32, idSectorGood: [9], descr: 'Cellulari e accessori', icon: 'fas fa-mobile-alt', color: 'blue' }, - { _id: 33, idSectorGood: [9], descr: 'Computer e software', icon: 'fas fa-laptop', color: 'grey' }, - { _id: 34, idSectorGood: [9], descr: 'Elettrodomestici', icon: 'fas fa-blender', color: 'green' }, - { _id: 35, idSectorGood: [9], descr: 'Fotografia', icon: 'fas fa-camera', color: 'black' }, - { _id: 36, idSectorGood: [9], descr: 'Videogiochi e console', icon: 'fas fa-gamepad', color: 'purple' }, - { _id: 37, idSectorGood: [10], descr: 'Console', icon: 'fas fa-gamepad', color: 'black' }, - { _id: 38, idSectorGood: [10], descr: 'Giochi di società', icon: 'fas fa-dice', color: 'yellow' }, - { _id: 39, idSectorGood: [10], descr: 'PC games', icon: 'fas fa-desktop', color: 'blue' }, - { _id: 40, idSectorGood: [11], descr: 'Attrezzatura', icon: 'fas fa-tools', color: 'grey' }, - { _id: 41, idSectorGood: [11], descr: 'Materiali', icon: 'fas fa-box-open', color: 'brown' }, - { _id: 42, idSectorGood: [11], descr: 'Prodotti', icon: 'fas fa-box', color: 'green' }, - { _id: 43, idSectorGood: [11], descr: 'Strumentazione', icon: 'fas fa-toolbox', color: 'blue' }, - { _id: 44, idSectorGood: [12], descr: ' riviste e fumetti', icon: 'fas fa-book-open', color: 'red' }, - { _id: 45, idSectorGood: [13], descr: 'CD e vinili', icon: 'fas fa-compact-disc', color: 'black' }, - { _id: 46, idSectorGood: [13], descr: 'Film e DVD', icon: 'fas fa-film', color: 'blue' }, - { _id: 47, idSectorGood: [13], descr: 'Strumenti musicali', icon: 'fas fa-guitar', color: 'brown' }, - { _id: 48, idSectorGood: [14], descr: 'Arredamento', icon: 'fas fa-couch', color: 'brown' }, - { _id: 49, idSectorGood: [14], descr: 'Attrezzature e accessori', icon: 'fas fa-tools', color: 'grey' }, - { _id: 50, idSectorGood: [14], descr: 'Cancelleria e cartucce', icon: 'fas fa-print', color: 'blue' }, - { _id: 51, idSectorGood: [15], descr: 'Abbigliamento', icon: 'fas fa-tshirt', color: 'purple' }, - { _id: 52, idSectorGood: [15], descr: 'Attrezzature e accessori Sport', icon: 'fas fa-football-ball', color: 'green' }, - { _id: 53, idSectorGood: [15], descr: 'Bici e accessori', icon: 'fas fa-bicycle', color: 'blue' }, - { _id: 54, idSectorGood: [17], descr: 'Edilizia', icon: 'fas fa-hard-hat', color: 'orange' }, - { _id: 55, idSectorGood: [17], descr: 'Modellismo', icon: 'fas fa-puzzle-piece', color: 'yellow' }, - { _id: 56, idSectorGood: [17], descr: 'Cucito', icon: 'fas fa-cut', color: 'pink' }, - { _id: 57, idSectorGood: [17], descr: 'Pulizia', icon: 'fas fa-broom', color: 'green' }, - { _id: 58, idSectorGood: [17], descr: 'Per Imbiancare', icon: 'fas fa-paint-roller', color: 'white' }, - { _id: 59, idSectorGood: [17], descr: 'Giardinaggio', icon: 'fas fa-seedling', color: 'green' }, - { _id: 60, idSectorGood: [17], descr: 'Falegnameria', icon: 'fas fa-hammer', color: 'brown' }, - { _id: 61, idSectorGood: [7], descr: 'Pane', icon: 'fas fa-bread-slice', color: 'brown' }, - { _id: 62, idSectorGood: [7], descr: 'Pasta', icon: 'fas fa-utensils', color: 'yellow' }, - { _id: 63, idSectorGood: [7], descr: 'Formaggi', icon: 'fas fa-cheese', color: 'yellow' }, - { _id: 64, idSectorGood: [7], descr: 'Olio', icon: 'fas fa-oil-can', color: 'green' }, - { _id: 65, idSectorGood: [7], descr: 'Fervida', icon: 'fas fa-fire', color: 'red' }, - { _id: 66, idSectorGood: [7], descr: 'Fermentati', icon: 'fas fa-beer', color: 'brown' }, - { _id: 67, idSectorGood: [7], descr: 'Marmellate', icon: 'fas fa-jar', color: 'orange' }, - { _id: 68, idSectorGood: [7], descr: 'Salse', icon: 'fas fa-mortar-pestle', color: 'red' }, - { _id: 69, idSectorGood: [20], descr: 'Cereali', icon: 'fas fa-wheat', color: 'yellow' }, - { _id: 70, idSectorGood: [20], descr: 'Frutta', icon: 'fas fa-apple-alt', color: 'red' }, - { _id: 71, idSectorGood: [20], descr: 'Ortaggi', icon: 'fas fa-carrot', color: 'orange' }, - { _id: 72, idSectorGood: [20], descr: 'Zootecnia', icon: 'fas fa-paw', color: 'brown' }, - { _id: 73, idSectorGood: [20], descr: 'Biologica', icon: 'fas fa-leaf', color: 'green' }, - { _id: 74, idSectorGood: [20], descr: 'Permacultura', icon: 'fas fa-recycle', color: 'green' }, - { _id: 75, idSectorGood: [20], descr: 'Sinergico', icon: 'fas fa-handshake', color: 'green' }, - { _id: 76, idSectorGood: [20], descr: 'Tradizionale', icon: 'fas fa-tractor', color: 'brown' }, - { _id: 77, idSectorGood: [20], descr: 'Viticoltura', icon: 'fas fa-wine-glass-alt', color: 'purple' }, - { _id: 78, idSectorGood: [20], descr: 'Acquacoltura', icon: 'fas fa-fish', color: 'blue' }, + { _id: 1, idSectorGood: [1], descr: 'Abbigliamento donna', icon: 'fas fa-tshirt' }, + { _id: 2, idSectorGood: [1], descr: 'Abbigliamento uomo', icon: 'fas fa-tshirt' }, + { _id: 3, idSectorGood: [1], descr: 'Accessori', icon: 'fas fa-glasses' }, + { _id: 4, idSectorGood: [1], descr: 'Scarpe donna', icon: 'fas fa-shoe-prints' }, + { _id: 5, idSectorGood: [1], descr: 'Scarpe uomo', icon: 'fas fa-shoe-prints' }, + { _id: 6, idSectorGood: [2], descr: 'Bagno', icon: 'fas fa-bath' }, + { _id: 7, idSectorGood: [2], descr: 'Camera', icon: 'fas fa-bed' }, + { _id: 8, idSectorGood: [2], descr: 'Complementi d\'arredo', icon: 'fas fa-couch' }, + { _id: 9, idSectorGood: [2], descr: 'Cucina', icon: 'fas fa-utensils' }, + { _id: 10, idSectorGood: [2], descr: 'Esterno', icon: 'fas fa-tree' }, + { _id: 11, idSectorGood: [2], descr: 'Soggiorno', icon: 'fas fa-tv' }, + { _id: 12, idSectorGood: [3], descr: 'Altri veicoli', icon: 'fas fa-car' }, + { _id: 13, idSectorGood: [3], descr: 'Auto', icon: 'fas fa-car' }, + { _id: 14, idSectorGood: [3], descr: 'Moto', icon: 'fas fa-motorcycle' }, + { _id: 15, idSectorGood: [3], descr: 'Camper', icon: 'fas fa-caravan' }, + { _id: 16, idSectorGood: [3], descr: 'Van (furgoni camperizzati)', icon: 'fas fa-truck' }, + { _id: 17, idSectorGood: [4], descr: 'Bigiotteria', icon: 'fas fa-gem' }, + { _id: 18, idSectorGood: [4], descr: 'Lavoretti', icon: 'fas fa-paint-brush' }, + { _id: 19, idSectorGood: [4], descr: 'Altro', icon: 'fas fa-question' }, + { _id: 20, idSectorGood: [5], descr: 'Accessori bellezza', icon: 'fas fa-spa' }, + { _id: 21, idSectorGood: [5], descr: 'Creme e detergenti', icon: 'fas fa-pump-soap' }, + { _id: 22, idSectorGood: [5], descr: 'Trucchi e profumi', icon: 'fas fa-palette' }, + { _id: 23, idSectorGood: [6], descr: 'Giocattoli e giochi di società', icon: 'fas fa-dice' }, + { _id: 24, idSectorGood: [6], descr: 'Igiene e pannolini', icon: 'fas fa-baby' }, + { _id: 25, idSectorGood: [6], descr: 'Lettini e culle', icon: 'fas fa-baby-carriage' }, + { _id: 26, idSectorGood: [6], descr: 'Passeggini & co', icon: 'fas fa-baby-carriage' }, + { _id: 27, idSectorGood: [6], descr: 'Vestiti e scarpe', icon: 'fas fa-socks' }, + { _id: 28, idSectorGood: [7], descr: 'Bere', icon: 'fas fa-glass-cheers' }, + { _id: 29, idSectorGood: [7], descr: 'Mangiare', icon: 'fas fa-utensils' }, + { _id: 30, idSectorGood: [8], descr: 'Antiquariato', icon: 'fas fa-history' }, + { _id: 31, idSectorGood: [8], descr: 'Collezionismo', icon: 'fas fa-coins' }, + { _id: 32, idSectorGood: [9], descr: 'Cellulari e accessori', icon: 'fas fa-mobile-alt' }, + { _id: 33, idSectorGood: [9], descr: 'Computer e software', icon: 'fas fa-laptop' }, + { _id: 34, idSectorGood: [9], descr: 'Elettrodomestici', icon: 'fas fa-blender' }, + { _id: 35, idSectorGood: [9], descr: 'Fotografia', icon: 'fas fa-camera' }, + { _id: 36, idSectorGood: [9], descr: 'Videogiochi e console', icon: 'fas fa-gamepad' }, + { _id: 37, idSectorGood: [10], descr: 'Console', icon: 'fas fa-gamepad' }, + { _id: 38, idSectorGood: [10], descr: 'Giochi di società', icon: 'fas fa-dice' }, + { _id: 39, idSectorGood: [10], descr: 'PC games', icon: 'fas fa-desktop' }, + { _id: 40, idSectorGood: [11], descr: 'Attrezzatura', icon: 'fas fa-tools' }, + { _id: 41, idSectorGood: [11], descr: 'Materiali', icon: 'fas fa-box-open' }, + { _id: 42, idSectorGood: [11], descr: 'Prodotti', icon: 'fas fa-box' }, + { _id: 43, idSectorGood: [11], descr: 'Strumentazione', icon: 'fas fa-toolbox' }, + { _id: 44, idSectorGood: [12], descr: ' riviste e fumetti', icon: 'fas fa-book-open' }, + { _id: 45, idSectorGood: [13], descr: 'CD e vinili', icon: 'fas fa-compact-disc' }, + { _id: 46, idSectorGood: [13], descr: 'Film e DVD', icon: 'fas fa-film' }, + { _id: 47, idSectorGood: [13], descr: 'Strumenti musicali', icon: 'fas fa-guitar' }, + { _id: 48, idSectorGood: [14], descr: 'Arredamento', icon: 'fas fa-couch' }, + { _id: 49, idSectorGood: [14], descr: 'Attrezzature e accessori', icon: 'fas fa-tools' }, + { _id: 50, idSectorGood: [14], descr: 'Cancelleria e cartucce', icon: 'fas fa-print' }, + { _id: 51, idSectorGood: [15], descr: 'Abbigliamento', icon: 'fas fa-tshirt' }, + { _id: 52, idSectorGood: [15], descr: 'Attrezzature e accessori Sport', icon: 'fas fa-football-ball' }, + { _id: 53, idSectorGood: [15], descr: 'Bici e accessori', icon: 'fas fa-bicycle' }, + { _id: 54, idSectorGood: [17], descr: 'Edilizia', icon: 'fas fa-hard-hat' }, + { _id: 55, idSectorGood: [17], descr: 'Modellismo', icon: 'fas fa-puzzle-piece' }, + { _id: 56, idSectorGood: [17], descr: 'Cucito', icon: 'fas fa-cut' }, + { _id: 57, idSectorGood: [17], descr: 'Pulizia', icon: 'fas fa-broom' }, + { _id: 58, idSectorGood: [17], descr: 'Per Imbiancare', icon: 'fas fa-paint-roller' }, + { _id: 59, idSectorGood: [17], descr: 'Giardinaggio', icon: 'fas fa-seedling' }, + { _id: 60, idSectorGood: [17], descr: 'Falegnameria', icon: 'fas fa-hammer' }, + { _id: 61, idSectorGood: [7], descr: 'Pane', icon: 'fas fa-bread-slice' }, + { _id: 62, idSectorGood: [7], descr: 'Pasta', icon: 'fas fa-utensils' }, + { _id: 63, idSectorGood: [7], descr: 'Formaggi', icon: 'fas fa-cheese' }, + { _id: 64, idSectorGood: [7], descr: 'Olio', icon: 'fas fa-oil-can' }, + { _id: 65, idSectorGood: [7], descr: 'Fervida', icon: 'fas fa-fire' }, + { _id: 66, idSectorGood: [7], descr: 'Fermentati', icon: 'fas fa-beer' }, + { _id: 67, idSectorGood: [7], descr: 'Marmellate', icon: 'fas fa-jar' }, + { _id: 68, idSectorGood: [7], descr: 'Salse', icon: 'fas fa-mortar-pestle' }, + { _id: 69, idSectorGood: [20], descr: 'Cereali', icon: 'fas fa-wheat' }, + { _id: 70, idSectorGood: [20], descr: 'Frutta', icon: 'fas fa-apple-alt' }, + { _id: 71, idSectorGood: [20], descr: 'Ortaggi', icon: 'fas fa-carrot' }, + { _id: 72, idSectorGood: [20], descr: 'Zootecnia', icon: 'fas fa-paw' }, + { _id: 73, idSectorGood: [20], descr: 'Biologica', icon: 'fas fa-leaf' }, + { _id: 74, idSectorGood: [20], descr: 'Permacultura', icon: 'fas fa-recycle' }, + { _id: 75, idSectorGood: [20], descr: 'Sinergico', icon: 'fas fa-handshake' }, + { _id: 76, idSectorGood: [20], descr: 'Tradizionale', icon: 'fas fa-tractor' }, + { _id: 77, idSectorGood: [20], descr: 'Viticoltura', icon: 'fas fa-wine-glass-alt' }, + { _id: 78, idSectorGood: [20], descr: 'Acquacoltura', icon: 'fas fa-fish' }, ], }; \ No newline at end of file diff --git a/src/populate/new_sectorbachecas.js b/src/populate/new_sectorbachecas.js new file mode 100644 index 0000000..84f63e1 --- /dev/null +++ b/src/populate/new_sectorbachecas.js @@ -0,0 +1,19 @@ +// new_sectorbachecas.js +module.exports = { + list: [ + { _id: 1, descr: 'Abitare Alternativo', icon: 'fas fa-home', color: 'brown-7' }, + { _id: 2, descr: 'Agricoltura e Permacultura', icon: 'fas fa-seedling', color: 'green-7' }, + { _id: 3, descr: 'Alimentazione Consapevole', icon: 'fas fa-apple-alt', color: 'orange-7' }, + { _id: 4, descr: 'Animali e Natura', icon: 'fas fa-paw', color: 'brown-6' }, + { _id: 5, descr: 'Benessere Olistico', icon: 'fas fa-spa', color: 'teal-6' }, + { _id: 6, descr: 'Cultura e Arte', icon: 'fas fa-palette', color: 'deep-purple-6' }, + { _id: 7, descr: 'Economia Solidale', icon: 'fas fa-handshake', color: 'amber-7' }, + { _id: 8, descr: 'Educazione Alternativa', icon: 'fas fa-book-reader', color: 'indigo-7' }, + { _id: 9, descr: 'Energie Rinnovabili', icon: 'fas fa-solar-panel', color: 'yellow-8' }, + { _id: 10, descr: 'Lavoro e Autoproduzione', icon: 'fas fa-hammer', color: 'grey-8' }, + { _id: 11, descr: 'Mobilità Sostenibile', icon: 'fas fa-bicycle', color: 'blue-7' }, + { _id: 12, descr: 'Progetti Comunitari', icon: 'fas fa-users', color: 'purple-7' }, + { _id: 13, descr: 'Salute Naturale', icon: 'fas fa-heart', color: 'red-6' }, + { _id: 14, descr: 'Tecnologie Appropriate', icon: 'fas fa-laptop-code', color: 'blue-grey-7' }, + ], +}; \ No newline at end of file diff --git a/src/populate/new_sectorgoods.js b/src/populate/new_sectorgoods.js new file mode 100644 index 0000000..73ab1c0 --- /dev/null +++ b/src/populate/new_sectorgoods.js @@ -0,0 +1,24 @@ +module.exports = { + list: [ + { _id: 1, descr: 'Abbigliamento e Accessori', icon: 'fas fa-tshirt', color: 'blue-7' }, + { _id: 2, descr: 'Arredamento e Casa', icon: 'fas fa-couch', color: 'brown-7' }, + { _id: 3, descr: 'Auto, Moto e Veicoli', icon: 'fas fa-car', color: 'grey-9' }, + { _id: 4, descr: 'Artigianato e Creazioni', icon: 'fas fa-gem', color: 'amber-7' }, + { _id: 5, descr: 'Bellezza e Cura Persona', icon: 'fas fa-spa', color: 'pink-7' }, + { _id: 6, descr: 'Infanzia e Bambini', icon: 'fas fa-baby', color: 'cyan-7' }, + { _id: 7, descr: 'Cibi e Bevande', icon: 'fas fa-apple-alt', color: 'orange-7' }, + { _id: 8, descr: 'Collezionismo e Antiquariato', icon: 'fas fa-coins', color: 'brown-9' }, + { _id: 9, descr: 'Elettronica e Tecnologia', icon: 'fas fa-laptop', color: 'blue-grey-8' }, + { _id: 10, descr: 'Gaming e Console', icon: 'fas fa-gamepad', color: 'purple-7' }, + { _id: 11, descr: 'Giardinaggio e Fai da Te', icon: 'fas fa-seedling', color: 'green-7' }, + { _id: 12, descr: 'Libri e Riviste', icon: 'fas fa-book-open', color: 'indigo-7' }, + { _id: 13, descr: 'Musica e Film', icon: 'fas fa-film', color: 'deep-purple-7' }, + { _id: 14, descr: 'Scuola e Ufficio', icon: 'fas fa-pen', color: 'blue-8' }, + { _id: 15, descr: 'Sport e Fitness', icon: 'fas fa-bicycle', color: 'green-8' }, + { _id: 16, descr: 'Animali', icon: 'fas fa-paw', color: 'brown-6' }, + { _id: 17, descr: 'Attrezzature e Strumenti', icon: 'fas fa-tools', color: 'grey-8' }, + { _id: 18, descr: 'Elettrodomestici', icon: 'fas fa-plug', color: 'teal-7' }, + { _id: 19, descr: 'Agricoltura e Orticoltura', icon: 'fas fa-tractor', color: 'green-9' }, + { _id: 20, descr: 'Arte e Decorazioni', icon: 'fas fa-palette', color: 'purple-6' }, + ], +}; diff --git a/src/populate/new_sectors.js b/src/populate/new_sectors.js new file mode 100644 index 0000000..c035ad9 --- /dev/null +++ b/src/populate/new_sectors.js @@ -0,0 +1,19 @@ +module.exports = { + list: [ + { _id: 1, descr: 'Abitare e Costruire', icon: 'fas fa-home', color: 'brown-7' }, + { _id: 2, descr: 'Agricoltura e Orticoltura', icon: 'fas fa-seedling', color: 'green-7' }, + { _id: 3, descr: 'Alimentazione e Trasformazione', icon: 'fas fa-apple-alt', color: 'orange-7' }, + { _id: 4, descr: 'Animali e Allevamento', icon: 'fas fa-paw', color: 'brown-6' }, + { _id: 5, descr: 'Artigianato e Creazione', icon: 'fas fa-hammer', color: 'amber-7' }, + { _id: 6, descr: 'Benessere e Cura Naturale', icon: 'fas fa-spa', color: 'teal-6' }, + { _id: 7, descr: 'Educazione e Formazione', icon: 'fas fa-book-reader', color: 'indigo-7' }, + { _id: 8, descr: 'Energia e Sostenibilità', icon: 'fas fa-solar-panel', color: 'yellow-8' }, + { _id: 9, descr: 'Manutenzione e Riparazione', icon: 'fas fa-tools', color: 'grey-8' }, + { _id: 10, descr: 'Mobilità e Trasporti', icon: 'fas fa-bicycle', color: 'blue-7' }, + { _id: 11, descr: 'Progetti Comunitari', icon: 'fas fa-users', color: 'purple-7' }, + { _id: 12, descr: 'Salute e Terapie', icon: 'fas fa-heart', color: 'red-6' }, + { _id: 13, descr: 'Tecnologie Appropriate', icon: 'fas fa-laptop-code', color: 'blue-grey-7' }, + { _id: 14, descr: 'Tessile e Sartoria', icon: 'fas fa-cut', color: 'pink-7' }, + { _id: 15, descr: 'Tempo Libero e Cultura', icon: 'fas fa-palette', color: 'deep-purple-6' }, + ], +}; diff --git a/src/populate/new_subskills.js b/src/populate/new_subskills.js new file mode 100644 index 0000000..83d3156 --- /dev/null +++ b/src/populate/new_subskills.js @@ -0,0 +1,157 @@ +module.exports = { + list: [ + // Abitare e Costruire + { _id: 1, idSector: [1], descr: 'Autocostruzione', icon: 'fas fa-hammer' }, + { _id: 2, idSector: [1], descr: 'Bioedilizia', icon: 'fas fa-leaf' }, + { _id: 3, idSector: [1], descr: 'Cohousing', icon: 'fas fa-home-heart' }, + { _id: 4, idSector: [1], descr: 'Ecovillaggi e Comunità', icon: 'fas fa-users' }, + { _id: 5, idSector: [1], descr: 'Immobili in Vendita', icon: 'fas fa-home' }, + { _id: 6, idSector: [1], descr: 'Immobili in Affitto', icon: 'fas fa-key' }, + { _id: 7, idSector: [1], descr: 'Stanze Condivise', icon: 'fas fa-door-open' }, + { _id: 8, idSector: [1], descr: 'Terreni', icon: 'fas fa-map' }, + + // Agricoltura e Orticoltura + { _id: 10, idSector: [2], descr: 'Aratura e Semina', icon: 'fas fa-tractor' }, + { _id: 11, idSector: [2], descr: 'Elettrocultura', icon: 'fas fa-bolt' }, + { _id: 12, idSector: [2], descr: 'Idroponica', icon: 'fas fa-flask' }, + { _id: 13, idSector: [2], descr: 'Orto Sinergico', icon: 'fas fa-seedling' }, + { _id: 14, idSector: [2], descr: 'Orto Tradizionale', icon: 'fas fa-carrot' }, + { _id: 15, idSector: [2], descr: 'Pacciamatura', icon: 'fas fa-layer-group' }, + { _id: 16, idSector: [2], descr: 'Permacultura', icon: 'fas fa-recycle' }, + { _id: 17, idSector: [2], descr: 'Potatura', icon: 'fas fa-cut' }, + { _id: 18, idSector: [2], descr: 'Raccolta', icon: 'fas fa-apple-alt' }, + + // Alimentazione e Trasformazione + { _id: 20, idSector: [3], descr: 'Autoproduzione Alimenti', icon: 'fas fa-jar' }, + { _id: 21, idSector: [3], descr: 'Autoproduzione Bevande', icon: 'fas fa-wine-bottle' }, + { _id: 22, idSector: [3], descr: 'Conservazione e Fermentazione', icon: 'fas fa-box' }, + { _id: 23, idSector: [3], descr: 'Home Restaurant', icon: 'fas fa-utensils' }, + { _id: 24, idSector: [3], descr: 'Panificazione', icon: 'fas fa-bread-slice' }, + + // Animali e Allevamento + { _id: 30, idSector: [4], descr: 'Allevamento Etico', icon: 'fas fa-horse' }, + { _id: 31, idSector: [4], descr: 'Apicoltura', icon: 'fas fa-bee' }, + { _id: 32, idSector: [4], descr: 'Cura Animali da Compagnia', icon: 'fas fa-paw' }, + { _id: 33, idSector: [4], descr: 'Veterinaria Olistica', icon: 'fas fa-stethoscope' }, + + // Artigianato e Creazione + { _id: 40, idSector: [5], descr: 'Ceramica e Terracotta', icon: 'fas fa-vase' }, + { _id: 41, idSector: [5], descr: 'Falegnameria', icon: 'fas fa-hammer' }, + { _id: 42, idSector: [5], descr: 'Lavorazione Metalli', icon: 'fas fa-anvil' }, + { _id: 43, idSector: [5], descr: 'Restauro', icon: 'fas fa-paint-brush' }, + { _id: 44, idSector: [5], descr: 'Sartoria e Ricamo', icon: 'fas fa-cut' }, + + // Benessere e Cura Naturale + { _id: 50, idSector: [6], descr: 'Alimentazione Naturale', icon: 'fas fa-leaf' }, + { _id: 51, idSector: [6], descr: 'Arteterapia', icon: 'fas fa-palette' }, + { _id: 52, idSector: [6], descr: 'Cantoterapia', icon: 'fas fa-music' }, + { _id: 53, idSector: [6], descr: 'Coach Motivazionale', icon: 'fas fa-bullhorn' }, + { _id: 54, idSector: [6], descr: 'Costellazioni Familiari', icon: 'fas fa-users' }, + { _id: 55, idSector: [6], descr: 'Fitoterapia', icon: 'fas fa-mortar-pestle' }, + { _id: 56, idSector: [6], descr: 'Floriterapia', icon: 'fas fa-flower' }, + { _id: 57, idSector: [6], descr: 'Ginnastica e Movimento', icon: 'fas fa-dumbbell' }, + { _id: 58, idSector: [6], descr: 'Kinesiologia', icon: 'fas fa-running' }, + { _id: 59, idSector: [6], descr: 'Massaggi', icon: 'fas fa-hands' }, + { _id: 60, idSector: [6], descr: 'Meditazione e Mindfulness', icon: 'fas fa-om' }, + { _id: 61, idSector: [6], descr: 'Naturopatia', icon: 'fas fa-leaf' }, + { _id: 62, idSector: [6], descr: 'Riflessologia', icon: 'fas fa-foot' }, + { _id: 63, idSector: [6], descr: 'Teatroterapia', icon: 'fas fa-theater-masks' }, + { _id: 64, idSector: [6], descr: 'Tecniche Essene', icon: 'fas fa-praying-hands' }, + { _id: 65, idSector: [6], descr: 'Trattamenti Energetici', icon: 'fas fa-hand-sparkles' }, + { _id: 66, idSector: [6], descr: 'Trattamenti Olistici', icon: 'fas fa-spa' }, + { _id: 67, idSector: [6], descr: 'Trattamenti Sonori', icon: 'fas fa-bell' }, + { _id: 68, idSector: [6], descr: 'Yoga', icon: 'fas fa-user-zen' }, + { _id: 69, idSector: [6], descr: 'Biodanza', icon: 'fas fa-seedling' }, + + // Educazione e Formazione + { _id: 70, idSector: [7], descr: 'Corsi e Workshop', icon: 'fas fa-chalkboard-teacher' }, + { _id: 71, idSector: [7], descr: 'Educazione Parentale', icon: 'fas fa-child' }, + { _id: 72, idSector: [7], descr: 'Formazione Tecnica', icon: 'fas fa-tools' }, + { _id: 73, idSector: [7], descr: 'Lingue', icon: 'fas fa-language' }, + { _id: 74, idSector: [7], descr: 'Scuola Libertaria', icon: 'fas fa-book-reader' }, + { _id: 75, idSector: [7], descr: 'Consulenze Professionali', icon: 'fas fa-briefcase' }, + + // Energia e Sostenibilità + { _id: 80, idSector: [8], descr: 'Biogas e Biomasse', icon: 'fas fa-fire' }, + { _id: 81, idSector: [8], descr: 'Compostaggio', icon: 'fas fa-recycle' }, + { _id: 82, idSector: [8], descr: 'Fotovoltaico', icon: 'fas fa-solar-panel' }, + { _id: 83, idSector: [8], descr: 'Gestione Rifiuti', icon: 'fas fa-trash-alt' }, + { _id: 84, idSector: [8], descr: 'Pompe di Calore', icon: 'fas fa-temperature-high' }, + { _id: 85, idSector: [8], descr: 'Solare Termico', icon: 'fas fa-sun' }, + { _id: 86, idSector: [8], descr: 'Stufe e Caminetti', icon: 'fas fa-fire-alt' }, + + // Manutenzione e Riparazione + { _id: 90, idSector: [9], descr: 'Arredamento', icon: 'fas fa-couch' }, + { _id: 91, idSector: [9], descr: 'Elettricista', icon: 'fas fa-plug' }, + { _id: 92, idSector: [9], descr: 'Fabbro', icon: 'fas fa-wrench' }, + { _id: 93, idSector: [9], descr: 'Giardiniere', icon: 'fas fa-leaf' }, + { _id: 94, idSector: [9], descr: 'Idraulico', icon: 'fas fa-faucet' }, + { _id: 95, idSector: [9], descr: 'Imbianchino', icon: 'fas fa-paint-roller' }, + { _id: 96, idSector: [9], descr: 'Muratore', icon: 'fas fa-hard-hat' }, + { _id: 97, idSector: [9], descr: 'Piastrellista', icon: 'fas fa-th' }, + { _id: 98, idSector: [9], descr: 'Pulizie', icon: 'fas fa-broom' }, + { _id: 99, idSector: [9], descr: 'Riparazione Elettrodomestici', icon: 'fas fa-blender' }, + { _id: 100, idSector: [9], descr: 'Traslochi', icon: 'fas fa-truck' }, + { _id: 101, idSector: [9], descr: 'Tuttofare', icon: 'fas fa-toolbox' }, + + // Mobilità e Trasporti + { _id: 110, idSector: [10], descr: 'Biciclette', icon: 'fas fa-bicycle' }, + { _id: 111, idSector: [10], descr: 'Camperizzazione', icon: 'fas fa-caravan' }, + { _id: 112, idSector: [10], descr: 'Car Sharing', icon: 'fas fa-car' }, + { _id: 113, idSector: [10], descr: 'Lavaggio Auto', icon: 'fas fa-water' }, + { _id: 114, idSector: [10], descr: 'Meccanica Auto', icon: 'fas fa-car-crash' }, + { _id: 115, idSector: [10], descr: 'Meccanica Moto', icon: 'fas fa-motorcycle' }, + + // Progetti Comunitari + { _id: 120, idSector: [11], descr: 'Banca del Tempo', icon: 'fas fa-clock' }, + { _id: 121, idSector: [11], descr: 'Collaborazioni', icon: 'fas fa-handshake' }, + { _id: 122, idSector: [11], descr: 'Eventi e Incontri', icon: 'fas fa-calendar-alt' }, + { _id: 123, idSector: [11], descr: 'Gruppi di Acquisto', icon: 'fas fa-shopping-basket' }, + { _id: 124, idSector: [11], descr: 'Laboratori', icon: 'fas fa-flask' }, + { _id: 125, idSector: [11], descr: 'Volontariato', icon: 'fas fa-hand-holding-heart' }, + { _id: 126, idSector: [11], descr: 'Servizi alla Comunità', icon: 'fas fa-hands-helping' }, + + // Salute e Terapie + { _id: 130, idSector: [12], descr: 'Counseling', icon: 'fas fa-comments' }, + { _id: 131, idSector: [12], descr: 'Dentista', icon: 'fas fa-tooth' }, + { _id: 132, idSector: [12], descr: 'Infermieristica', icon: 'fas fa-user-nurse' }, + { _id: 133, idSector: [12], descr: 'Medicina di Base', icon: 'fas fa-user-md' }, + { _id: 134, idSector: [12], descr: 'Medicina Naturale', icon: 'fas fa-leaf' }, + { _id: 135, idSector: [12], descr: 'Nutrizionista', icon: 'fas fa-apple-alt' }, + { _id: 136, idSector: [12], descr: 'Omeopatia', icon: 'fas fa-vial' }, + { _id: 137, idSector: [12], descr: 'OSS', icon: 'fas fa-briefcase-medical' }, + { _id: 138, idSector: [12], descr: 'Ostetrica', icon: 'fas fa-baby' }, + { _id: 139, idSector: [12], descr: 'Pediatra', icon: 'fas fa-child' }, + { _id: 140, idSector: [12], descr: 'Psicologo', icon: 'fas fa-brain' }, + { _id: 141, idSector: [12], descr: 'Psicoterapeuta', icon: 'fas fa-couch' }, + { _id: 142, idSector: [12], descr: 'Specialisti', icon: 'fas fa-stethoscope' }, + + // Tecnologie Appropriate + { _id: 150, idSector: [13], descr: 'Assistenza Cellulari', icon: 'fas fa-mobile-alt' }, + { _id: 151, idSector: [13], descr: 'Assistenza PC', icon: 'fas fa-laptop' }, + { _id: 152, idSector: [13], descr: 'Corsi Informatica', icon: 'fas fa-graduation-cap' }, + { _id: 153, idSector: [13], descr: 'Realizzazione App', icon: 'fas fa-mobile' }, + { _id: 154, idSector: [13], descr: 'Realizzazione Siti Web', icon: 'fas fa-globe' }, + { _id: 155, idSector: [13], descr: 'Software Libero', icon: 'fas fa-code' }, + + // Tessile e Sartoria + { _id: 160, idSector: [14], descr: 'Autoproduzione Abbigliamento', icon: 'fas fa-tshirt' }, + { _id: 161, idSector: [14], descr: 'Filatura', icon: 'fas fa-spinner' }, + { _id: 162, idSector: [14], descr: 'Riparazioni Tessili', icon: 'fas fa-sewing-machine' }, + { _id: 163, idSector: [14], descr: 'Sartoria su Misura', icon: 'fas fa-ruler' }, + { _id: 164, idSector: [14], descr: 'Tessitura', icon: 'fas fa-grip-lines' }, + { _id: 165, idSector: [14], descr: 'Tingere Naturale', icon: 'fas fa-tint' }, + + // Tempo Libero e Cultura + { _id: 170, idSector: [15], descr: 'Arte e Pittura', icon: 'fas fa-palette' }, + { _id: 171, idSector: [15], descr: 'Ballo', icon: 'fas fa-dancing' }, + { _id: 172, idSector: [15], descr: 'Canto', icon: 'fas fa-microphone' }, + { _id: 173, idSector: [15], descr: 'Film Making', icon: 'fas fa-video' }, + { _id: 174, idSector: [15], descr: 'Fotografia', icon: 'fas fa-camera' }, + { _id: 175, idSector: [15], descr: 'Letteratura', icon: 'fas fa-book' }, + { _id: 176, idSector: [15], descr: 'Musica', icon: 'fas fa-music' }, + { _id: 177, idSector: [15], descr: 'Sport', icon: 'fas fa-running' }, + { _id: 178, idSector: [15], descr: 'Teatro', icon: 'fas fa-theater-masks' }, + { _id: 179, idSector: [15], descr: 'Altre Attività Culturali', icon: 'fas fa-question' }, + ], +}; diff --git a/src/populate/populate.js b/src/populate/populate.js index 89c9e06..eccd613 100644 --- a/src/populate/populate.js +++ b/src/populate/populate.js @@ -5,6 +5,7 @@ const Path = require('path'); const mongoose = require('mongoose').set('debug', false) const shared_consts = require('../tools/shared_nodejs'); +const migration = require('./migration-categories'); module.exports = { @@ -190,6 +191,9 @@ module.exports = { } } + // FAI LA MIGRAZIONE + migration.runMigration(); + console.log('FINE - popolaTabelleNuove'); return true; diff --git a/src/populate/sectors.js b/src/populate/sectors.js deleted file mode 100644 index 11de7e2..0000000 --- a/src/populate/sectors.js +++ /dev/null @@ -1,41 +0,0 @@ -/* -module.exports = { - list: [ - { _id: 2, descr: 'Agricoltura', icon: 'fas fa-tractor', color: '#4CAF50' }, - { _id: 3, descr: 'Cibo e Ristorazione', icon: 'fas fa-utensils', color: '#FF9800' }, - { _id: 4, descr: 'Animali', icon: 'fas fa-paw', color: '#795548' }, - { _id: 5, descr: 'Auto e Veicoli', icon: 'fas fa-car', color: '#607D8B' }, - { _id: 6, descr: 'Salute e Benessere', icon: 'fas fa-heartbeat', color: '#E91E63' }, - { _id: 7, descr: 'Casa e Arredamento', icon: 'fas fa-home', color: '#9C27B0' }, - { _id: 8, descr: 'Attività Ricreative e di Intrattenim.', icon: 'fas fa-gamepad', color: '#FF5722' }, - { _id: 13, descr: 'Tecnologie', icon: 'fas fa-microchip', color: '#2196F3' }, - { _id: 15, descr: 'Artigianato', icon: 'fas fa-hammer', color: '#FFC107' }, - { _id: 16, descr: 'Arte e Cultura', icon: 'fas fa-palette', color: '#3F51B5' }, - { _id: 17, descr: 'Assistenza e Integrazione', icon: 'fas fa-hands-helping', color: '#00BCD4' }, - { _id: 18, descr: 'Attività fisica e sportiva', icon: 'fas fa-running', color: '#8BC34A' }, - { _id: 20, descr: 'Bambini', icon: 'fas fa-baby', color: '#FFEB3B' }, - { _id: 21, descr: 'Consulenza e Supporto Professionale', icon: 'fas fa-briefcase', color: '#9E9E9E' }, - { _id: 22, descr: 'Formazione e crescita personale', icon: 'fas fa-graduation-cap', color: '#673AB7' }, - { _id: 23, descr: 'Manutenzione e riparazione', icon: 'fas fa-wrench', color: '#F44336' }, - { _id: 24, descr: 'Mobilità e Trasporti', icon: 'fas fa-bus', color: '#009688' }, - ], -}; -*/ - -module.exports = { - list: [ - {_id: 1, descr: 'Abitare'}, - {_id: 2, descr: 'Agricoltura'}, - {_id: 3, descr: 'Alimentazione'}, - {_id: 4, descr: 'Animali'}, - {_id: 5, descr: 'Auto e Veicoli'}, - {_id: 6, descr: 'Benessere'}, - {_id: 7, descr: 'Per la Casa'}, - {_id: 8, descr: 'Intrattenimento'}, - {_id: 10, descr: 'Per la Persona'}, - {_id: 11, descr: 'Progetti di Gruppo'}, - {_id: 12, descr: 'Salute'}, - {_id: 13, descr: 'Tecnologie'}, - {_id: 14, descr: 'Servizi'}, - ], -}; \ No newline at end of file diff --git a/src/router/index_router.js b/src/router/index_router.js index 724d401..7aa5047 100755 --- a/src/router/index_router.js +++ b/src/router/index_router.js @@ -54,11 +54,13 @@ const { MyElem } = require('../models/myelem'); const { Cron } = require('../models/cron'); const { Skill } = require('../models/skill'); const { Good } = require('../models/good'); +const { Bacheca } = require('../models/bacheca'); const { StatusSkill } = require('../models/statusSkill'); const { Province } = require('../models/province'); const { City } = require('../models/city'); const { Sector } = require('../models/sector'); const { SectorGood } = require('../models/sectorgood'); +const { SectorBacheca } = require('../models/sectorbacheca'); const { CatGrp } = require('../models/catgrp'); const Site = require('../models/site'); const { Level } = require('../models/level'); @@ -2262,7 +2264,9 @@ async function load(req, res, version = '0') { adtypes: version >= 91 ? AdType.findAllIdApp(idapp) : Promise.resolve([]), adtypegoods: version >= 91 ? AdTypeGood.findAllIdApp(idapp) : Promise.resolve([]), sectorgoods: version >= 91 ? SectorGood.findAllIdApp(idapp) : Promise.resolve([]), + sectorbachecas: version >= 91 ? SectorBacheca.findAllIdApp(idapp) : Promise.resolve([]), goods: version >= 91 ? Good.findAllIdApp(idapp) : Promise.resolve([]), + bachecas: version >= 91 ? Bacheca.findAllIdApp(idapp) : Promise.resolve([]), site: version >= 91 ? Site.findAllIdApp(idapp) : Promise.resolve([]), mygroups: version >= 91 ? MyGroup.findAllGroups(idapp) : Promise.resolve([]), listcircuits: version >= 91 ? Circuit.findAllIdApp(idapp) : Promise.resolve([]), @@ -2407,6 +2411,8 @@ async function load(req, res, version = '0') { crons: data.crons, raccoltacataloghis: data.raccoltacataloghis, statuscode2: data.statuscode2, + sectorbachecas: data.sectorbachecas, + bachecas: data.bachecas, }; } diff --git a/src/tools/general.js b/src/tools/general.js index 158e68a..4f9a599 100755 --- a/src/tools/general.js +++ b/src/tools/general.js @@ -1654,7 +1654,7 @@ module.exports = { if (!giainviato && cmd !== shared_consts.CIRCUITCMD.REQ) { extrarec.send_email = await User.isEnableToReceiveEmailByUsernameECmd(idapp, usernameOrig, cmd); - + // SEND TO THE USER DEST THE NOTIFICATION ris = await this.sendNotifCircuitByUsername( cmd, @@ -2155,7 +2155,9 @@ module.exports = { getLinkGruppiTerritorialiTelegram: function (idapp) { try { const myapp = this.MYAPPS.find((item) => item.idapp === idapp); - return myapp && myapp.telegram_gruppi_territoriali_senzainvito ? myapp.telegram_gruppi_territoriali_senzainvito : ''; + return myapp && myapp.telegram_gruppi_territoriali_senzainvito + ? myapp.telegram_gruppi_territoriali_senzainvito + : ''; } catch (e) { return ''; } @@ -5203,7 +5205,22 @@ module.exports = { let mystr = ''; const rec = secgoodrec.find((rec) => rec._id === myrec.idSectorGood); - // const rec = goodrec.find((rec) => rec._id === myrec.idSectorGood); + if (rec) { + mystr += rec.descr; + } + return mystr; + } catch (e) {} + }, + async getCategoriaBachecaByRec(myrec) { + const { SectorBacheca } = require('../models/sectorbacheca'); + + try { + const idapp = myrec.idapp; + if (!idapp) return ''; + const secbachecarec = await SectorBacheca.findAllIdApp(idapp); + + let mystr = ''; + const rec = secbachecarec.find((rec) => rec._id === myrec.idSectorBacheca); if (rec) { mystr += rec.descr; } @@ -5417,6 +5434,7 @@ module.exports = { } else if (tablerec === shared_consts.TABLES_MYHOSPS) { cat = ''; } else if (tablerec === shared_consts.TABLES_MYBACHECAS) { + cat = await this.getCategoriaBachecaByRec(myrec); if (myrec.website) { sitoweb = myrec.website; } @@ -6378,4 +6396,20 @@ module.exports = { } } }, + + /* Converte una stringa di versione (es. "1.2.55") in un numero per confronti + * @param {string} version - Stringa versione in formato "major.minor.patch" + * @returns {number} Numero rappresentante la versione + */ + versionToNumber(version) { + const parts = version.split('.').map((num) => parseInt(num, 10)); + + // Gestisce versioni con 1, 2 o 3 componenti + const major = parts[0] || 0; + const minor = parts[1] || 0; + const patch = parts[2] || 0; + + // Usa padding di 3 cifre per minor e patch (supporta fino a 999) + return major * 1000000 + minor * 1000 + patch; + }, }; diff --git a/src/tools/globalTables.js b/src/tools/globalTables.js index c181085..ad1a614 100755 --- a/src/tools/globalTables.js +++ b/src/tools/globalTables.js @@ -26,6 +26,7 @@ const { Skill } = require('../models/skill'); const { Catalog } = require('../models/catalog'); const { RaccoltaCataloghi } = require('../models/raccoltacataloghi'); const { Good } = require('../models/good'); +const { Bacheca } = require('../models/bacheca'); const { SubSkill } = require('../models/subskill'); const { MySkill } = require('../models/myskill'); const { Attivita } = require('../models/attivita'); @@ -171,6 +172,7 @@ module.exports = { else if (tablename === 'catalogs') mytable = Catalog; else if (tablename === 'raccoltacataloghis') mytable = RaccoltaCataloghi; else if (tablename === 'goods') mytable = Good; + else if (tablename === 'bachecas') mytable = Bacheca; else if (tablename === 'subskills') mytable = SubSkill; else if (tablename === shared_consts.TABLES_MYSKILLS) mytable = MySkill; else if (tablename === shared_consts.TABLES_ATTIVITAS) mytable = Attivita; diff --git a/src/tools/shared_nodejs.js b/src/tools/shared_nodejs.js index 5a9c3e9..7e99378 100755 --- a/src/tools/shared_nodejs.js +++ b/src/tools/shared_nodejs.js @@ -205,7 +205,7 @@ module.exports = { TABLES_GETCOMPLETEREC: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'attivitas'], //++Todo: per abilitare gli utenti ad inserire un Circuito aggiungere 'circuits' alla lista TABLES_PERM_NEWREC - TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps', 'catalogs', 'raccoltacataloghis'], + TABLES_PERM_NEWREC: ['skills', 'goods', 'bachecas', 'subskills', 'mygroups', 'myhosps', 'catalogs', 'raccoltacataloghis'], TABLES_REACTIONS: ['mybachecas', 'myhosps', 'myskills', 'mygoods', 'attivitas'], @@ -233,6 +233,8 @@ module.exports = { 'sectors', 'goods', 'sectorgoods', + 'bachecas', + 'sectorbachecas', 'catgrps', 'skills', 'subskills', @@ -962,10 +964,9 @@ module.exports = { } else if (table === this.TABLES_MYBACHECAS) { proj = { recSkill: 1, - sector: 1, - idSector: 1, - idSkill: 1, - // 'idSubSkill': 1, + idSectorBacheca: 1, + idBacheca: 1, + sectorBacheca: 1, idStatusSkill: 1, idContribType: 1, dateTimeStart: 1, @@ -1327,4 +1328,8 @@ module.exports = { }, TOK_INIZIALE_VERIF_TELEG: '', + + JOB_TO_EXECUTE: { + MIGRATION_SECTORS_DIC25: 'Migration_Sectors_Dic_2025', + }, }; diff --git a/src/version.txt b/src/version.txt index e2355b2..3bacf4a 100644 --- a/src/version.txt +++ b/src/version.txt @@ -1 +1 @@ -1.2.85 \ No newline at end of file +1.2.86 \ No newline at end of file