@adobe/spacecat-shared-data-access 1.1.2 → 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,17 @@
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
+
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)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * switch defaults to dev (force release) ([b85d54c](https://github.com/adobe-rnd/spacecat-shared/commit/b85d54ca7430a4e54b49d112429242c81ff55714))
14
+
1
15
  # [@adobe/spacecat-shared-data-access-v1.1.2](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.1.1...@adobe/spacecat-shared-data-access-v1.1.2) (2023-12-02)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "1.1.2",
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",
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@adobe/spacecat-shared-dynamo": "1.2.3",
32
+ "@adobe/spacecat-shared-dynamo": "1.2.4",
33
33
  "@adobe/spacecat-shared-utils": "1.2.0",
34
34
  "@aws-sdk/client-dynamodb": "3.465.0",
35
35
  "@aws-sdk/lib-dynamodb": "3.465.0",
package/src/index.js CHANGED
@@ -12,12 +12,12 @@
12
12
 
13
13
  import { createDataAccess } from './service/index.js';
14
14
 
15
- const TABLE_NAME_AUDITS = 'spacecat-services-audits';
16
- const TABLE_NAME_LATEST_AUDITS = 'spacecat-services-latest-audits';
17
- const TABLE_NAME_SITES = 'spacecat-services-sites';
15
+ const TABLE_NAME_AUDITS = 'spacecat-services-audits-dev';
16
+ const TABLE_NAME_LATEST_AUDITS = 'spacecat-services-latest-audits-dev';
17
+ const TABLE_NAME_SITES = 'spacecat-services-sites-dev';
18
18
 
19
- const INDEX_NAME_ALL_SITES = 'spacecat-services-all-sites';
20
- const INDEX_NAME_ALL_LATEST_AUDIT_SCORES = 'spacecat-services-all-latest-audit-scores';
19
+ const INDEX_NAME_ALL_SITES = 'spacecat-services-all-sites-dev';
20
+ const INDEX_NAME_ALL_LATEST_AUDIT_SCORES = 'spacecat-services-all-latest-audit-scores-dev';
21
21
 
22
22
  const PK_ALL_SITES = 'ALL_SITES';
23
23
  const PK_ALL_LATEST_AUDITS = 'ALL_LATEST_AUDITS';
@@ -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
  }