Skip to content

Commit

Permalink
fix: suspicious logic to update triggerValue
Browse files Browse the repository at this point in the history
  • Loading branch information
gulfaraz committed Sep 12, 2024
1 parent c377b55 commit 36fc8f2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions services/API-service/src/api/event/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -876,18 +876,22 @@ export class EventService {
eventArea.triggerValue = affectedArea.triggerValue;
eventArea.actionsValue = affectedArea.actionsValue;
eventAreasToUpdate.push(
`('${eventArea.eventPlaceCodeId}',${eventArea.actionsValue})`,
`('${eventArea.eventPlaceCodeId}',${eventArea.actionsValue},${eventArea.triggerValue})`,
);
}
}
if (eventAreasToUpdate.length) {
const repository = this.dataSource.getRepository(EventPlaceCodeEntity);
const updateQuery = `UPDATE "${repository.metadata.schema}"."${
repository.metadata.tableName
}" epc \
SET "actionsValue" = areas.value::double precision \
FROM (VALUES ${eventAreasToUpdate.join(',')}) areas(id,value) \
WHERE areas.id::uuid = epc."eventPlaceCodeId" \
const updateQuery = `UPDATE \
"${repository.metadata.schema}"."${repository.metadata.tableName}" epc \
SET \
"actionsValue" = areas.actionValue::double precision, \
"triggerValue" = areas.triggerValue::double precision \
FROM \
(VALUES ${eventAreasToUpdate.join(',')}) \
areas(id, actionValue, triggerValue) \
WHERE \
areas.id::uuid = epc."eventPlaceCodeId" \
`;
await this.dataSource.query(updateQuery);
}
Expand Down

0 comments on commit 36fc8f2

Please sign in to comment.