Skip to content

Commit

Permalink
Merge branch 'main' into migration-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
solaris007 authored Dec 31, 2024
2 parents 24d1844 + a51afa1 commit 84500d2
Showing 9 changed files with 461 additions and 29 deletions.
464 changes: 440 additions & 24 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions packages/spacecat-shared-data-access/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@adobe/spacecat-shared-data-access-v1.61.8](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.61.7...@adobe/spacecat-shared-data-access-v1.61.8) (2024-12-31)


### Bug Fixes

* logging ([#515](https://github.com/adobe/spacecat-shared/issues/515)) ([a0010ea](https://github.com/adobe/spacecat-shared/commit/a0010eae6ff87b04c065568c1af135736cfdbcfd))

# [@adobe/spacecat-shared-data-access-v1.61.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.61.6...@adobe/spacecat-shared-data-access-v1.61.7) (2024-12-31)


2 changes: 1 addition & 1 deletion packages/spacecat-shared-data-access/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/spacecat-shared-data-access",
"version": "1.61.7",
"version": "1.61.8",
"description": "Shared modules of the Spacecat Services - Data Access",
"type": "module",
"engines": {
Original file line number Diff line number Diff line change
@@ -377,6 +377,9 @@ class BaseCollection {
const instance = this.#createInstance(record.data);

this.#invalidateCache();

this.log.info(`Created item for [${this.entityName}]`);

await this.#onCreate(instance);

return instance;
@@ -491,6 +494,8 @@ class BaseCollection {
this.log.error(`Failed to process all items in batch write for [${this.entityName}]: ${JSON.stringify(response.unprocessed)}`);
}

this.log.info(`Updated ${items.length} items for [${this.entityName}]`);

return this.#invalidateCache();
} catch (error) {
return this.#logAndThrowError('Failed to save many', error);
@@ -513,11 +518,12 @@ class BaseCollection {
}

try {
this.log.info(`Removing ${ids.length} items for [${this.entityName}]`);
// todo: consider removing dependent records

await this.entity.delete(ids.map((id) => ({ [this.idName]: id }))).go();

this.log.info(`Removed ${ids.length} items for [${this.entityName}]`);

return this.#invalidateCache();
} catch (error) {
return this.#logAndThrowError('Failed to remove by IDs', error);
Original file line number Diff line number Diff line change
@@ -346,7 +346,7 @@ class Schema {
requiredKeys: subset,
});

log.info(`Created accessors for index [${indexName}] with keys [${subset.join(', ')}]`);
log.debug(`Created accessors for index [${indexName}] with keys [${subset.join(', ')}]`);
});
});

Original file line number Diff line number Diff line change
@@ -48,6 +48,8 @@ class SuggestionCollection extends BaseCollection {

await this._saveMany(suggestions);

this.log.info(`Bulk updated ${suggestions.length} suggestions to status: ${status}`);

return suggestions;
}
}
Original file line number Diff line number Diff line change
@@ -153,6 +153,6 @@ export function createAccessor(config) { /* eslint-disable no-underscore-dangle
export function createAccessors(configs, log) {
configs.forEach((config) => {
createAccessor(config);
log.info(`Created accessor ${config.name} for ${config.context.schema.getModelName()} to ${config.collection.schema.getModelName()}`);
log.debug(`Created accessor ${config.name} for ${config.context.schema.getModelName()} to ${config.collection.schema.getModelName()}`);
});
}
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ describe('BaseCollection', () => {

mockLogger = {
error: spy(),
debug: spy(),
info: spy(),
warn: spy(),
};
Original file line number Diff line number Diff line change
@@ -322,7 +322,7 @@ describe('BaseModel', () => { /* eslint-disable no-underscore-dangle */
);

expect(result).to.be.an.instanceOf(BaseModel);
expect(mockLogger.debug).to.have.been.calledOnceWithExactly('No sort keys defined for Opportunity to Suggestions');
expect(mockLogger.debug).to.have.been.calledWithExactly('No sort keys defined for Opportunity to Suggestions');
});
});
});

0 comments on commit 84500d2

Please sign in to comment.