Skip to content

Commit 5e3eb12

Browse files
review comments
1 parent 5793d93 commit 5e3eb12

File tree

8 files changed

+8
-125
lines changed

8 files changed

+8
-125
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ SpaceCat Task Processor is a Node.js service that processes messages from the AW
2727
1. Clone the repository
2828
2. Install dependencies:
2929
```sh
30-
npm ci
30+
npm install
3131
```
3232
3. Configure AWS credentials and environment variables as needed
3333

scripts/populate-env.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

scripts/watch-and-copy.js

Lines changed: 0 additions & 82 deletions
This file was deleted.

src/index.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
*/
1212
import wrap from '@adobe/helix-shared-wrap';
1313
import { helixStatus } from '@adobe/helix-status';
14-
import secrets from '@adobe/helix-shared-secrets';
1514
import dataAccess from '@adobe/spacecat-shared-data-access';
1615
import { sqsEventAdapter } from '@adobe/spacecat-shared-utils';
1716
import { internalServerError, notFound, ok } from '@adobe/spacecat-shared-http-utils';
@@ -27,14 +26,6 @@ const HANDLERS = {
2726
dummy: (message) => ok(message),
2827
};
2928

30-
// Custom secret name resolver to use the correct secret path
31-
function getSecretName() {
32-
return '/helix-deploy/spacecat-services/api-service/latest';
33-
}
34-
35-
// Export for testing
36-
export { getSecretName };
37-
3829
function getElapsedSeconds(startTime) {
3930
const endTime = process.hrtime(startTime);
4031
const elapsedSeconds = endTime[0] + endTime[1] / 1e9;
@@ -76,5 +67,4 @@ async function run(message, context) {
7667
export const main = wrap(run)
7768
.with(dataAccess)
7869
.with(sqsEventAdapter)
79-
.with(secrets, { name: getSecretName })
8070
.with(helixStatus);

src/tasks/demo-url-processor/handler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import { say } from '../../utils/slack-utils.js';
1616
const TASK_TYPE = 'demo-url-processor';
1717

1818
/**
19-
* Runs the audit status processor
20-
* @param {object} demoUrlMessage - The demoUrlMessage object
19+
* Runs the demo url processor
20+
* @param {object} message - The message object
2121
* @param {object} context - The context object
2222
*/
2323
export async function runDemoUrlProcessor(message, context) {

src/tasks/opportunity-status-processor/handler.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export async function runOpportunityStatusProcessor(message, context) {
6262

6363
try {
6464
// Get the site and its opportunities
65-
const site = await Site.findByBaseURL(`https://${siteId}.com`);
65+
const site = await Site.findById(siteId);
6666
if (!site) {
6767
log.error(`Site not found for siteId: ${siteId}`);
6868
await say(env, log, slackContext, `:x: Site not found for siteId: ${siteId}`);
@@ -83,10 +83,8 @@ export async function runOpportunityStatusProcessor(message, context) {
8383
continue;
8484
}
8585
processedTypes.add(opportunityType);
86-
8786
// eslint-disable-next-line no-await-in-loop
8887
const suggestions = await opportunity.getSuggestions();
89-
9088
// Get the opportunity title
9189
const opportunityTitle = getOpportunityTitle(opportunityType);
9290
const hasSuggestions = suggestions && suggestions.length > 0;

test/index.test.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import sinon from 'sinon';
1717
import sinonChai from 'sinon-chai';
1818
import { Request } from '@adobe/fetch';
1919
import esmock from 'esmock';
20-
import { main, getSecretName } from '../src/index.js';
20+
import { main } from '../src/index.js';
2121

2222
use(sinonChai);
2323

@@ -97,18 +97,10 @@ describe('Index Tests', () => {
9797
expect(resp.status).to.equal(200);
9898
// Verify the task handler was found
9999
expect(context.log.info.calledWith('Found task handler for type: dummy')).to.be.true;
100-
// Print all log.info calls for debugging
101-
// eslint-disable-next-line no-console
102-
console.log('log.info calls:', context.log.info.getCalls().map((call) => call.args[0]));
103100
// Verify the task completion message (using partial match since timing varies)
104101
expect(context.log.info.calledWithMatch(sinon.match('dummy task for site-id completed in'))).to.be.true;
105102
});
106103

107-
it('should cover getSecretName function', () => {
108-
const secretName = getSecretName();
109-
expect(secretName).to.equal('/helix-deploy/spacecat-services/api-service/latest');
110-
});
111-
112104
it('should handle handler throwing an error', async () => {
113105
// Test a handler type that doesn't exist to trigger the catch block
114106
messageBodyJson.type = 'opportunity-status-processor';

test/tasks/opportunity-status-processor/opportunity-status-processor.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('Opportunity Status Processor', () => {
4747
.withSandbox(sandbox)
4848
.withDataAccess({
4949
Site: {
50-
findByBaseURL: sandbox.stub().resolves(mockSite),
50+
findById: sandbox.stub().resolves(mockSite),
5151
},
5252
})
5353
.build();
@@ -91,13 +91,13 @@ describe('Opportunity Status Processor', () => {
9191
auditTypes: ['cwv', 'broken-links'],
9292
})).to.be.true;
9393

94-
expect(context.dataAccess.Site.findByBaseURL.calledWith('https://test-site-id.com')).to.be.true;
94+
expect(context.dataAccess.Site.findById.calledWith('test-site-id')).to.be.true;
9595
expect(mockSite.getOpportunities.called).to.be.true;
9696
expect(context.log.info.calledWith('Found 2 opportunities for site test-site-id')).to.be.true;
9797
});
9898

9999
it('should handle site not found error', async () => {
100-
context.dataAccess.Site.findByBaseURL.resolves(null);
100+
context.dataAccess.Site.findById.resolves(null);
101101

102102
await runOpportunityStatusProcessor(message, context);
103103

0 commit comments

Comments
 (0)