@adobe/spacecat-shared-data-access 1.1.3 → 1.1.5
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 +14 -0
- package/package.json +1 -1
- package/src/service/audits/accessPatterns.js +18 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v1.1.5](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.1.4...@adobe/spacecat-shared-data-access-v1.1.5) (2023-12-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* get audit no query ([#34](https://github.com/adobe-rnd/spacecat-shared/issues/34)) ([8fadd0a](https://github.com/adobe-rnd/spacecat-shared/commit/8fadd0a21a1e0cc232a06ccf805d1ac5c946b8be))
|
|
7
|
+
|
|
8
|
+
# [@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)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* latest-audits sort key ([#33](https://github.com/adobe-rnd/spacecat-shared/issues/33)) ([21dc14e](https://github.com/adobe-rnd/spacecat-shared/commit/21dc14e75e8aad641f1c99330243a3102e8de465))
|
|
14
|
+
|
|
1
15
|
# [@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
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -65,17 +65,12 @@ export const getAuditForSite = async (
|
|
|
65
65
|
auditType,
|
|
66
66
|
auditedAt,
|
|
67
67
|
) => {
|
|
68
|
-
const audit = await dynamoClient.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
ExpressionAttributeValues: {
|
|
72
|
-
':siteId': siteId,
|
|
73
|
-
':sk': `${auditType}#${auditedAt}`,
|
|
74
|
-
},
|
|
75
|
-
Limit: 1,
|
|
68
|
+
const audit = await dynamoClient.getItem(config.tableNameAudits, {
|
|
69
|
+
siteId,
|
|
70
|
+
SK: `${auditType}#${auditedAt}`,
|
|
76
71
|
});
|
|
77
72
|
|
|
78
|
-
return audit
|
|
73
|
+
return audit ? AuditDto.fromDynamoItem(audit) : null;
|
|
79
74
|
};
|
|
80
75
|
|
|
81
76
|
/**
|
|
@@ -158,10 +153,10 @@ export const getLatestAuditForSite = async (
|
|
|
158
153
|
) => {
|
|
159
154
|
const latestAudit = await dynamoClient.query({
|
|
160
155
|
TableName: config.tableNameLatestAudits,
|
|
161
|
-
KeyConditionExpression: 'siteId = :siteId AND
|
|
156
|
+
KeyConditionExpression: 'siteId = :siteId AND auditType = :auditType',
|
|
162
157
|
ExpressionAttributeValues: {
|
|
163
158
|
':siteId': siteId,
|
|
164
|
-
':auditType': `${auditType}
|
|
159
|
+
':auditType': `${auditType}`,
|
|
165
160
|
},
|
|
166
161
|
Limit: 1,
|
|
167
162
|
});
|
|
@@ -221,13 +216,18 @@ async function removeAudits(
|
|
|
221
216
|
) {
|
|
222
217
|
const tableName = latest ? config.tableNameLatestAudits : config.tableNameAudits;
|
|
223
218
|
// TODO: use batch-remove (needs dynamo client update)
|
|
224
|
-
const removeAuditPromises = audits.map((audit) =>
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
219
|
+
const removeAuditPromises = audits.map((audit) => {
|
|
220
|
+
const sortKey = latest
|
|
221
|
+
? { auditType: `${audit.getAuditType()}` }
|
|
222
|
+
: { SK: `${audit.getAuditType()}#${audit.getAuditedAt()}` };
|
|
223
|
+
return dynamoClient.removeItem(
|
|
224
|
+
tableName,
|
|
225
|
+
{
|
|
226
|
+
siteId: audit.getSiteId(),
|
|
227
|
+
...sortKey,
|
|
228
|
+
},
|
|
229
|
+
);
|
|
230
|
+
});
|
|
231
231
|
|
|
232
232
|
await Promise.all(removeAuditPromises);
|
|
233
233
|
}
|