Skip to content

Commit

Permalink
Thing
Browse files Browse the repository at this point in the history
  • Loading branch information
palmertab committed Dec 16, 2024
1 parent 590c5d0 commit 4b2eccc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
12 changes: 9 additions & 3 deletions api/controllers/tab/round/blast.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ export const blastRoundPairing = {
sender = req.session.person;
}

const roundId = rawRoundId || req.params.roundId;
const roundId = parseInt(rawRoundId) || req.params.roundId;

console.log(`Round is ${roundId}`);

const queryData = {};
queryData.replacements = { roundId };
Expand All @@ -212,6 +214,8 @@ export const blastRoundPairing = {

if (req.body.publish) {

console.log(`QUeryData is ${JSON.stringify(queryData)}`);

const publish = req.db.sequelize.query(
`update round set published = 1 where round.id = :roundId `, {
replacements : queryData.replacements,
Expand Down Expand Up @@ -281,6 +285,8 @@ export const blastRoundPairing = {

const blastResponse = await sendPairingBlast(followers, blastData, req, res);

console.log(`blast response is ${JSON.stringify(blastResponse)}`);

if (req.session?.person) {
const person = { personId : req.session?.person };

Expand All @@ -292,7 +298,7 @@ export const blastRoundPairing = {
`, {
replacements : {
tournId : req.params.tournId,
description : `Pairing blast sent. ${blastResponse.message} ${req.session?.person ? '' : 'by autoblast'} `,
description : `Pairing blast sent. ${blastResponse?.message} ${req.session?.person ? '' : 'by autoblast'} `,
roundId,
...person,
},
Expand All @@ -308,7 +314,7 @@ export const blastRoundPairing = {
('tabbing', :description, :roundId, :tournId, NOW())
`, {
replacements: {
description : `Pairing blast sent. ${blastResponse.message} ${req.session?.person ? '' : 'by autoblast'} `,
description : `Pairing blast sent. ${blastResponse?.message} ${req.session?.person ? '' : 'by autoblast'} `,
...req.params,
},
type : req.db.sequelize.QueryTypes.INSERT,
Expand Down
11 changes: 7 additions & 4 deletions api/helpers/pairing.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,17 +634,20 @@ export const sendPairingBlast = async (followers, blastData, req, res) => {
});
}

const returnMessage = Promise.all(logPromises).then( () => {
Promise.all(logPromises).then( () => {
resolve({
error : false,
message : `Pairings sent to ${blastResponse.web} web and ${blastResponse.email} email recipients`,
web : blastResponse.web,
email : blastResponse.email,
});
});

resolve(returnMessage);

resolve({
error : false,
message : `Pairings sent to ${blastResponse.web} web and ${blastResponse.email} email recipients`,
web : blastResponse.web,
email : blastResponse.email,
});
});
});

Expand Down

0 comments on commit 4b2eccc

Please sign in to comment.