Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/NGC-1784-20250331.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const main = async () => {
let updatedPolls = 0

for await (const poll of batchPolls) {
await updatePollFunFacts(poll.id, { session: prisma })
await updatePollFunFacts({ pollId: poll.id }, { session: prisma })

updatedPolls++

Expand Down
1 change: 1 addition & 0 deletions src/adapters/redis/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const CHANNELS = {
}

export const KEYS = {
pollsFunFactsResults: 'pollsFunFactsResults',
geolocationSortedIps: 'geolocationSortedIps',
geolocationCountries: 'geolocationCountries',
}
16 changes: 14 additions & 2 deletions src/features/groups/groups.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const createGroupAndUser = async (
const [participantDto] = participants || []

// For now no relation
const [group, simulation] = await Promise.all([
const [group, simulationCreation] = await Promise.all([
// create group
session.group.create({
data: {
Expand Down Expand Up @@ -111,7 +111,11 @@ export const createGroupAndUser = async (
: []),
])

const { created, simulation, updated } = simulationCreation || {}

return {
simulationUpdated: updated,
simulationCreated: created,
administrator,
simulation,
group: {
Expand Down Expand Up @@ -185,7 +189,7 @@ export const createParticipantAndUser = async (

// For now no relation
const { id: simulationId } = simulationDto
const [simulation, participant] = await Promise.all([
const [simulationCreation, participant] = await Promise.all([
createParticipantSimulation(
{
userId,
Expand Down Expand Up @@ -217,11 +221,19 @@ export const createParticipantAndUser = async (
}),
])

const {
created: simulationCreated,
simulation,
updated: simulationUpdated,
} = simulationCreation

return {
participant: {
...participant,
simulation,
},
simulationUpdated,
simulationCreated,
created: !existingParticipant,
updated: !!existingParticipant,
}
Expand Down
21 changes: 15 additions & 6 deletions src/features/groups/groups.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,13 @@ export const createGroup = async ({
groupDto: GroupCreateDto
origin: string
}) => {
const { group, administrator, simulation } = await transaction((session) =>
createGroupAndUser(groupDto, { session })
)
const {
group,
administrator,
simulation,
simulationUpdated,
simulationCreated,
} = await transaction((session) => createGroupAndUser(groupDto, { session }))
const { participants } = group

const events = []
Expand All @@ -130,6 +134,8 @@ export const createGroup = async ({
administrator,
sendEmail: true,
user: administrator,
updated: simulationUpdated,
created: simulationCreated,
})

EventBus.emit(simulationUpsertedEvent)
Expand Down Expand Up @@ -180,9 +186,10 @@ export const createParticipant = async ({
participantDto: ParticipantCreateDto
}) => {
try {
const { participant, created } = await transaction((session) =>
createParticipantAndUser(params, participantDto, { session })
)
const { participant, created, simulationCreated, simulationUpdated } =
await transaction((session) =>
createParticipantAndUser(params, participantDto, { session })
)
const {
user,
group,
Expand All @@ -198,6 +205,8 @@ export const createParticipant = async ({
})

const simulationUpsertedEvent = new SimulationUpsertedEvent({
created: simulationCreated,
updated: simulationUpdated,
sendEmail: created,
administrator,
simulation,
Expand Down
Loading