fix(FalukantService): update userHouse query attributes and transaction handling
All checks were successful
Deploy to production / deploy (push) Successful in 1m52s
All checks were successful
Deploy to production / deploy (push) Successful in 1m52s
- Modified the userHouse query to include 'id' in the attributes, improving data retrieval. - Enhanced transaction handling in state and userHouse updates to ensure atomic operations, preventing potential data inconsistencies.
This commit is contained in:
@@ -3902,7 +3902,7 @@ class FalukantService extends BaseService {
|
|||||||
|
|
||||||
const userHouse = await UserHouse.findOne({
|
const userHouse = await UserHouse.findOne({
|
||||||
where: { userId: user.id },
|
where: { userId: user.id },
|
||||||
attributes: ['householdOrder']
|
attributes: ['id', 'householdOrder']
|
||||||
});
|
});
|
||||||
|
|
||||||
const marriage = await Relationship.findOne({
|
const marriage = await Relationship.findOne({
|
||||||
@@ -3988,7 +3988,7 @@ class FalukantService extends BaseService {
|
|||||||
|
|
||||||
const userHouse = await UserHouse.findOne({
|
const userHouse = await UserHouse.findOne({
|
||||||
where: { userId: user.id },
|
where: { userId: user.id },
|
||||||
attributes: ['householdOrder']
|
attributes: ['id', 'householdOrder']
|
||||||
});
|
});
|
||||||
const productionDelayMinutes = 15;
|
const productionDelayMinutes = 15;
|
||||||
const runningProductions = await Production.findAll({
|
const runningProductions = await Production.findAll({
|
||||||
@@ -4011,14 +4011,18 @@ class FalukantService extends BaseService {
|
|||||||
let delayedProductions = 0;
|
let delayedProductions = 0;
|
||||||
|
|
||||||
await sequelize.transaction(async (t) => {
|
await sequelize.transaction(async (t) => {
|
||||||
await state.update({
|
await state.update(
|
||||||
marriageSatisfaction: nextSatisfaction,
|
{
|
||||||
marriagePublicStability: nextPublicStability
|
marriageSatisfaction: nextSatisfaction,
|
||||||
});
|
marriagePublicStability: nextPublicStability
|
||||||
|
},
|
||||||
|
{ transaction: t }
|
||||||
|
);
|
||||||
if (userHouse && nextHouseholdOrder != null) {
|
if (userHouse && nextHouseholdOrder != null) {
|
||||||
await userHouse.update({
|
await userHouse.update(
|
||||||
householdOrder: nextHouseholdOrder
|
{ householdOrder: nextHouseholdOrder },
|
||||||
});
|
{ transaction: t }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
for (const production of runningProductions) {
|
for (const production of runningProductions) {
|
||||||
const startAt = new Date(production.startTimestamp);
|
const startAt = new Date(production.startTimestamp);
|
||||||
|
|||||||
Reference in New Issue
Block a user