Skip to content

Commit

Permalink
Bugfix - wasn't saving runs
Browse files Browse the repository at this point in the history
This is what happens when DDB condition strings rely on field names.
  • Loading branch information
mikebroberts committed Nov 20, 2024
1 parent ab82175 commit 2529053
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
})
}

Expand Down
12 changes: 6 additions & 6 deletions test/testSupport/fakes/tableRecordExpectedWrites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
)
Expand All @@ -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
}
}
)
Expand Down

0 comments on commit 2529053

Please sign in to comment.