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
44 changes: 1 addition & 43 deletions api/routes/loadout-share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import {
} from '../shapes/loadout-share.js';
import { Loadout } from '../shapes/loadouts.js';
import { UserInfo } from '../shapes/user.js';
import {
deleteLoadoutShare,
getLoadoutShare as getLoadoutShareStately,
} from '../stately/loadout-share-queries.js';
import slugify from './slugify.js';
import { validateLoadout } from './update.js';

Expand Down Expand Up @@ -129,43 +125,5 @@ export async function loadLoadoutShare(shareId: string) {
recordAccess(client, shareId),
);

if (loadout) {
return loadout;
}

// Fall back to Stately, and backfill into Postgres if found
const result = await getLoadoutShareStately(shareId);
if (!result) {
return undefined;
}

// Backfill in Postgres
const backfilled = await transaction(async (client) => {
try {
await addLoadoutShare(
client,
undefined,
result.platformMembershipId,
shareId,
result.loadout,
result.viewCount,
);
return true;
} catch (e) {
// This is a unique constraint violation, give up
if (e instanceof DatabaseError && e.code === '23505') {
await client.query('ROLLBACK');
return false;
} else {
throw e;
}
}
});

if (backfilled) {
// Remove from Stately only if we successfully backfilled
await deleteLoadoutShare(shareId);
}

return result.loadout;
return loadout;
}
2 changes: 1 addition & 1 deletion kubernetes/dim-api-stately-backfill-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
- name: BACKFILL_PARALLEL_SEGMENTS
value: '4'
- name: BACKFILL_TOKEN_PATH
value: /var/lib/dim-api-backfill/backfill-token.bin
value: /var/lib/dim-api-backfill/backfill-token2.bin
- name: BACKFILL_RETRY_MAX_ATTEMPTS
value: '12'
- name: BACKFILL_RETRY_BASE_DELAY_MS
Expand Down
Loading