Skip to content

Commit 1df4118

Browse files
authored
Merge pull request #256 from DestinyItemManager/update-validate
Only attempt updates that pass validation
2 parents 378c8cb + 0ba0578 commit 1df4118

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

api/routes/update.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ export const updateHandler = asyncHandler(async (req, res) => {
125125
migrationState.state !== desiredMigrationState;
126126

127127
const results: ProfileUpdateResult[] = validateUpdates(req, updates, platformMembershipId, appId);
128+
// Only attempt updates that pass validation
129+
const updatesToApply = updates.filter((_, index) => results[index].status === 'Success');
128130

129131
const importToStately = async () => {
130132
// Export from Postgres
@@ -161,18 +163,24 @@ export const updateHandler = asyncHandler(async (req, res) => {
161163
// For now let's leave the old data in Postgres as a backup
162164
await doMigration(bungieMembershipId, importToStately);
163165
await statelyUpdate(
164-
updates,
166+
updatesToApply,
165167
bungieMembershipId,
166168
platformMembershipId ?? profileIds[0],
167169
destinyVersion,
168170
);
169171
} else {
170-
await pgUpdate(updates, bungieMembershipId, platformMembershipId, destinyVersion, appId);
172+
await pgUpdate(
173+
updatesToApply,
174+
bungieMembershipId,
175+
platformMembershipId,
176+
destinyVersion,
177+
appId,
178+
);
171179
}
172180
break;
173181
case MigrationState.Stately:
174182
await statelyUpdate(
175-
updates,
183+
updatesToApply,
176184
bungieMembershipId,
177185
platformMembershipId ?? profileIds[0],
178186
destinyVersion,

0 commit comments

Comments
 (0)