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
6 changes: 1 addition & 5 deletions packages/spacecat-shared-data-access/docs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"AttributeType": "S"
},
"SortKey": {
"AttributeName": "SK",
"AttributeName": "auditType",
"AttributeType": "S"
}
},
Expand All @@ -214,10 +214,6 @@
"AttributeName": "auditResult",
"AttributeType": "M"
},
{
"AttributeName": "auditType",
"AttributeType": "S"
},
{
"AttributeName": "expiresAt",
"AttributeType": "N"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ export const getLatestAuditForSite = async (
) => {
const latestAudit = await dynamoClient.query({
TableName: config.tableNameLatestAudits,
KeyConditionExpression: 'siteId = :siteId AND begins_with(SK, :auditType)',
KeyConditionExpression: 'siteId = :siteId AND begins_with(auditType, :auditType)',
ExpressionAttributeValues: {
':siteId': siteId,
':auditType': `${auditType}#`,
':auditType': `${auditType}`,
},
Limit: 1,
});
Expand Down Expand Up @@ -221,13 +221,18 @@ async function removeAudits(
) {
const tableName = latest ? config.tableNameLatestAudits : config.tableNameAudits;
// TODO: use batch-remove (needs dynamo client update)
const removeAuditPromises = audits.map((audit) => dynamoClient.removeItem(
tableName,
{
siteId: audit.getSiteId(),
SK: `${audit.getAuditType()}#${audit.getAuditedAt()}`,
},
));
const removeAuditPromises = audits.map((audit) => {
const sortKey = latest
? { auditType: `${audit.getAuditType()}` }
: { SK: `${audit.getAuditType()}#${audit.getAuditedAt()}` };
return dynamoClient.removeItem(
tableName,
{
siteId: audit.getSiteId(),
...sortKey,
},
);
});

await Promise.all(removeAuditPromises);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function generateAuditData(
// Modify the audit data for the latest_audits table
let GSI1SK = `${audit.auditType}#`;
if (audit.auditType === 'lhs-mobile') {
GSI1SK += Object.values(audit.auditResult).map((score) => (parseFloat(score) * 100).toFixed(0)).join('#');
GSI1SK += Object.values(audit.auditResult.scores).map((score) => (parseFloat(score) * 100).toFixed(0)).join('#');
} else {
GSI1SK += Object.values(audit.auditResult).join('#');
}
Expand Down