@adobe/spacecat-shared-data-access 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [@adobe/spacecat-shared-data-access-v1.1.4](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.1.3...@adobe/spacecat-shared-data-access-v1.1.4) (2023-12-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * latest-audits sort key ([#33](https://github.com/adobe-rnd/spacecat-shared/issues/33)) ([21dc14e](https://github.com/adobe-rnd/spacecat-shared/commit/21dc14e75e8aad641f1c99330243a3102e8de465))
7
+
1
8
  # [@adobe/spacecat-shared-data-access-v1.1.3](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.1.2...@adobe/spacecat-shared-data-access-v1.1.3) (2023-12-05)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -158,10 +158,10 @@ export const getLatestAuditForSite = async (
158
158
  ) => {
159
159
  const latestAudit = await dynamoClient.query({
160
160
  TableName: config.tableNameLatestAudits,
161
- KeyConditionExpression: 'siteId = :siteId AND begins_with(SK, :auditType)',
161
+ KeyConditionExpression: 'siteId = :siteId AND begins_with(auditType, :auditType)',
162
162
  ExpressionAttributeValues: {
163
163
  ':siteId': siteId,
164
- ':auditType': `${auditType}#`,
164
+ ':auditType': `${auditType}`,
165
165
  },
166
166
  Limit: 1,
167
167
  });
@@ -221,13 +221,18 @@ async function removeAudits(
221
221
  ) {
222
222
  const tableName = latest ? config.tableNameLatestAudits : config.tableNameAudits;
223
223
  // TODO: use batch-remove (needs dynamo client update)
224
- const removeAuditPromises = audits.map((audit) => dynamoClient.removeItem(
225
- tableName,
226
- {
227
- siteId: audit.getSiteId(),
228
- SK: `${audit.getAuditType()}#${audit.getAuditedAt()}`,
229
- },
230
- ));
224
+ const removeAuditPromises = audits.map((audit) => {
225
+ const sortKey = latest
226
+ ? { auditType: `${audit.getAuditType()}` }
227
+ : { SK: `${audit.getAuditType()}#${audit.getAuditedAt()}` };
228
+ return dynamoClient.removeItem(
229
+ tableName,
230
+ {
231
+ siteId: audit.getSiteId(),
232
+ ...sortKey,
233
+ },
234
+ );
235
+ });
231
236
 
232
237
  await Promise.all(removeAuditPromises);
233
238
  }