Skip to content

Commit 9aeeade

Browse files
review changes
1 parent 4f8947f commit 9aeeade

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

infrastructure/terraform/components/api/module_lambda_supplier_allocator.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ data "aws_iam_policy_document" "supplier_allocator_lambda" {
106106
"dynamodb:GetItem",
107107
"dynamodb:Query",
108108
"dynamodb:PutItem",
109-
"dynamodb:UpdateItem"
109+
"dynamodb:UpdateItem",
110+
"dynamodb:DeleteItem"
110111
]
111112

112113
resources = [

lambdas/supplier-allocator/src/handler/allocate-handler.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ async function saveAllocations(
268268
}
269269

270270
type SupplierAllocationResult = {
271-
supplier: string;
272271
priority: string;
272+
supplier: string;
273273
};
274274

275275
async function processSupplierAllocation(
@@ -331,13 +331,13 @@ async function processSupplierAllocation(
331331
}),
332332
);
333333
return {
334-
supplier,
335334
priority,
335+
supplier,
336336
};
337337
}
338338

339339
export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler {
340-
const getSupplierIdempotently = (
340+
const createGetSupplierIdempotently = (
341341
perAllocationSuccess: AllocationMetrics,
342342
perAllocationFailure: AllocationMetrics,
343343
volumeGroupAllocations: VolumeGroupAllocation,
@@ -363,8 +363,8 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler {
363363
const perAllocationFailure: AllocationMetrics = new Map();
364364
const volumeGroupAllocations: VolumeGroupAllocation = new Map();
365365

366-
// create an idempotent function bound to this handler's batchItemFailures
367-
const boundGetSupplierIdempotently = getSupplierIdempotently(
366+
// create an idempotent function bound to this handler's global variables to track metrics and allocations
367+
const getSupplierIdempotently = createGetSupplierIdempotently(
368368
perAllocationSuccess,
369369
perAllocationFailure,
370370
volumeGroupAllocations,
@@ -387,10 +387,9 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler {
387387
idempotencyConfig.registerLambdaContext(context);
388388

389389
const supplierAllocationResult: SupplierAllocationResult =
390-
await boundGetSupplierIdempotently(letterEvent, deps);
390+
await getSupplierIdempotently(letterEvent, deps);
391391

392-
supplier = supplierAllocationResult.supplier;
393-
priority = supplierAllocationResult.priority;
392+
({ priority, supplier } = supplierAllocationResult);
394393
} catch (error) {
395394
deps.logger.error({
396395
description: "Error processing allocation of record",

tests/config/main.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ const localConfig: PlaywrightTestConfig = {
2727
dependencies: ["apiGateway-tests"],
2828
},
2929
{
30-
name: "letterQueue-tests", // Needs to run last as tests visibility timeout and can impact other tests if run before them
31-
testDir: path.resolve(__dirname, "../component-tests/letterQueue-tests"),
30+
name: "allocation-tests",
31+
testDir: path.resolve(__dirname, "../component-tests/allocation-tests"),
3232
testMatch: "**/*.spec.ts",
33-
dependencies: ["events-tests"],
3433
},
3534
{
36-
name: "allocation-tests",
37-
testDir: path.resolve(__dirname, "../component-tests/allocation-tests"),
35+
name: "letterQueue-tests", // Needs to run last as tests visibility timeout and can impact other tests if run before them
36+
testDir: path.resolve(__dirname, "../component-tests/letterQueue-tests"),
3837
testMatch: "**/*.spec.ts",
38+
dependencies: ["events-tests"],
3939
},
4040
],
4141
};

0 commit comments

Comments
 (0)