From 25290537d38364d43fe383d8e132bc64e56705af Mon Sep 17 00:00:00 2001 From: Mike Roberts Date: Wed, 20 Nov 2024 12:16:33 -0500 Subject: [PATCH] Bugfix - wasn't saving runs This is what happens when DDB condition strings rely on field names. --- .../entities/GithubLatestWorkflowRunEventEntity.ts | 6 +++--- .../entityStore/entities/GithubWorkflowRunEntity.ts | 6 +++--- test/testSupport/fakes/tableRecordExpectedWrites.ts | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/app/domain/entityStore/entities/GithubLatestWorkflowRunEventEntity.ts b/src/app/domain/entityStore/entities/GithubLatestWorkflowRunEventEntity.ts index ee3482b..7fffa13 100644 --- a/src/app/domain/entityStore/entities/GithubLatestWorkflowRunEventEntity.ts +++ b/src/app/domain/entityStore/entities/GithubLatestWorkflowRunEventEntity.ts @@ -45,9 +45,9 @@ export async function putRunEventIfNoKeyExistsOrNewerThanExisting( event: GithubWorkflowRunEvent ) { return await store(entityStore).put(event, { - conditionExpression: 'attribute_not_exists(PK) OR #updatedAt < :newUpdatedAt', - expressionAttributeNames: { '#updatedAt': 'updatedAt' }, - expressionAttributeValues: { ':newUpdatedAt': event.runEventUpdatedAt } + conditionExpression: 'attribute_not_exists(PK) OR #runEventUpdatedAt < :newRunEventUpdatedAt', + expressionAttributeNames: { '#runEventUpdatedAt': 'runEventUpdatedAt' }, + expressionAttributeValues: { ':newRunEventUpdatedAt': event.runEventUpdatedAt } }) } diff --git a/src/app/domain/entityStore/entities/GithubWorkflowRunEntity.ts b/src/app/domain/entityStore/entities/GithubWorkflowRunEntity.ts index da9fbc2..89d452b 100644 --- a/src/app/domain/entityStore/entities/GithubWorkflowRunEntity.ts +++ b/src/app/domain/entityStore/entities/GithubWorkflowRunEntity.ts @@ -60,9 +60,9 @@ export async function putGithubWorkflowRunfNoKeyExistsOrNewerThanExisting( event: GithubWorkflowRunEvent ) { return await store(entityStore).put(event, { - conditionExpression: 'attribute_not_exists(PK) OR #updatedAt < :newUpdatedAt', - expressionAttributeNames: { '#updatedAt': 'updatedAt' }, - expressionAttributeValues: { ':newUpdatedAt': event.runEventUpdatedAt } + conditionExpression: 'attribute_not_exists(PK) OR #runEventUpdatedAt < :newRunEventUpdatedAt', + expressionAttributeNames: { '#runEventUpdatedAt': 'runEventUpdatedAt' }, + expressionAttributeValues: { ':newRunEventUpdatedAt': event.runEventUpdatedAt } }) } diff --git a/test/testSupport/fakes/tableRecordExpectedWrites.ts b/test/testSupport/fakes/tableRecordExpectedWrites.ts index 5a2b653..1c8c62e 100644 --- a/test/testSupport/fakes/tableRecordExpectedWrites.ts +++ b/test/testSupport/fakes/tableRecordExpectedWrites.ts @@ -99,12 +99,12 @@ export function expectedPutGithubWorkflowRun(event: GithubWorkflowRunEvent) { ...event }, { - ConditionExpression: 'attribute_not_exists(PK) OR #updatedAt < :newUpdatedAt', + ConditionExpression: 'attribute_not_exists(PK) OR #runEventUpdatedAt < :newRunEventUpdatedAt', ExpressionAttributeNames: { - '#updatedAt': 'updatedAt' + '#runEventUpdatedAt': 'runEventUpdatedAt' }, ExpressionAttributeValues: { - ':newUpdatedAt': event.runEventUpdatedAt + ':newRunEventUpdatedAt': event.runEventUpdatedAt } } ) @@ -122,12 +122,12 @@ export function expectedPutLatestGithubWorkflowRunEvent(event: GithubWorkflowRun ...event }, { - ConditionExpression: 'attribute_not_exists(PK) OR #updatedAt < :newUpdatedAt', + ConditionExpression: 'attribute_not_exists(PK) OR #runEventUpdatedAt < :newRunEventUpdatedAt', ExpressionAttributeNames: { - '#updatedAt': 'updatedAt' + '#runEventUpdatedAt': 'runEventUpdatedAt' }, ExpressionAttributeValues: { - ':newUpdatedAt': event.runEventUpdatedAt + ':newRunEventUpdatedAt': event.runEventUpdatedAt } } )