From 8b9c336f5d9e0b2926bf5e56698097936eb0bb0d Mon Sep 17 00:00:00 2001 From: Bastien Seree Date: Mon, 23 Dec 2024 11:57:35 +0100 Subject: [PATCH] EDF: [#165] Ensure there is one admin dashboard in db --- .../web/server/plugins/entreprisedufutur/functions.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/web/server/plugins/entreprisedufutur/functions.js b/backend/web/server/plugins/entreprisedufutur/functions.js index d35729da5..4db66a2cc 100644 --- a/backend/web/server/plugins/entreprisedufutur/functions.js +++ b/backend/web/server/plugins/entreprisedufutur/functions.js @@ -43,6 +43,7 @@ const { computeUrl: ComputeDomain } = require('../../../config/config') const { getTagUrl } = require('../../utils/mailing') const { getterPartnerList } = require('./admin_dashboard') const { getUnknownEmails, getInputsValid } = require('./order') +const AdminDashboard = require('../../models/AdminDashboard') //Notification plugin setup setAllowedTypes(NOTIFICATION_TYPES) @@ -577,6 +578,16 @@ const ensureMarketScore = async () => { ensureMarketScore() +const ensureAdminDashboard = async () => { + return AdminDashboard.findOneAndUpdate( + {}, + {}, + {upsert: true} + ) +} + +ensureAdminDashboard() + const preprocessGet = async ({model, fields, id, user, params}) => { //console.log('preGet : model', model, 'fields', fields, 'id', id, 'user', user, 'params', params) if (model=='loggedUser') {