From 3d56ee05c122529239361e23ed58439218accdea Mon Sep 17 00:00:00 2001 From: robertoooc Date: Sat, 7 Oct 2023 16:51:34 -0700 Subject: [PATCH] added logic to clear cache when updating badge so user info is up to date --- src/controllers/badgeController.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/controllers/badgeController.js b/src/controllers/badgeController.js index 6238c381e..e3768884a 100644 --- a/src/controllers/badgeController.js +++ b/src/controllers/badgeController.js @@ -2,6 +2,7 @@ const mongoose = require('mongoose'); const UserProfile = require('../models/userProfile'); const { hasPermission, hasIndividualPermission } = require('../utilities/permissions'); const escapeRegex = require('../utilities/escapeRegex'); +const cache = require('../utilities/nodeCache')(); const badgeController = function (Badge) { const getAllBadges = async function (req, res) { @@ -47,6 +48,8 @@ const badgeController = function (Badge) { if (result) { record.badgeCollection = req.body.badgeCollection; + if (cache.hasCache(`user-${userToBeAssigned}`)) cache.removeCache(`user-${userToBeAssigned}`); + record.save() .then(results => res.status(201).send(results._id)) .catch(errors => res.status(500).send(errors));