Servey change
This commit is contained in:
parent
1dd952dd24
commit
3ff51c489e
@ -3,6 +3,7 @@ const { Op } = require("sequelize");
|
||||
const { Sequelize } = require("sequelize");
|
||||
const QuarterlyWindowsConfiguration = db.QuarterlyWindowsConfiguration;
|
||||
const Establishment = db.Establishment;
|
||||
const EstablishmentUser = db.EstablishmentUser;
|
||||
|
||||
// Create new configuration
|
||||
exports.createConfig = async (req, res) => {
|
||||
@ -21,13 +22,23 @@ exports.createConfig = async (req, res) => {
|
||||
const assignedCount = await Establishment.count({
|
||||
where: { is_active: true }
|
||||
});
|
||||
|
||||
|
||||
// set auto values before inserting
|
||||
req.body.assigned = assignedCount;
|
||||
req.body.responded = 0;
|
||||
req.body.not_responded = assignedCount;
|
||||
req.body.created_by = req.body.created_by || req.user.id;
|
||||
|
||||
const EstablishmentUserData = await EstablishmentUser.findAll({where: { establishment_id: result.establishment_id, is_active: 1 }});
|
||||
const establishmentEmailPromises = EstablishmentUserData.map((userObj) => {
|
||||
console.log("Sending email to Establishment User:", userObj.email);
|
||||
return sendEmailService(userObj.email,"submission_created_mail_to_establishment_user",{...basePlaceholder,user_name: userObj.name,});
|
||||
});
|
||||
|
||||
await Promise.all([
|
||||
...establishmentEmailPromises
|
||||
]);
|
||||
|
||||
const data = await QuarterlyWindowsConfiguration.create(req.body);
|
||||
res.status(201).send({
|
||||
status: "success",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user