-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Rafraichir le cache LCMS en asynchrone (pgboss)
- Loading branch information
Showing
8 changed files
with
63 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { JobPgBoss } from '../JobPgBoss.js'; | ||
|
||
class LcmsRefreshCacheJob extends JobPgBoss { | ||
constructor(queryBuilder) { | ||
super({ name: 'LcmsRefreshCacheJob', retryLimit: 0 }, queryBuilder); | ||
} | ||
} | ||
|
||
export { LcmsRefreshCacheJob }; |
18 changes: 18 additions & 0 deletions
18
api/lib/infrastructure/jobs/lcms/LcmsRefreshCacheJobHandler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { LcmsRefreshCacheJob } from './LcmsRefreshCacheJob.js'; | ||
|
||
class LcmsRefreshCacheJobHandler { | ||
constructor({ learningContentDatasource, logger }) { | ||
this.logger = logger; | ||
this.learningContentDatasource = learningContentDatasource; | ||
} | ||
|
||
async handle() { | ||
await this.learningContentDatasource.refreshLearningContentCacheRecords(); | ||
} | ||
|
||
get name() { | ||
return LcmsRefreshCacheJob.name; | ||
} | ||
} | ||
|
||
export { LcmsRefreshCacheJobHandler }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
api/src/shared/domain/usecases/refresh-learning-content-cache.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const refreshLearningContentCache = async function ({ lcmsRefreshCacheJob }) { | ||
await lcmsRefreshCacheJob.schedule(); | ||
}; | ||
export { refreshLearningContentCache }; |
15 changes: 15 additions & 0 deletions
15
api/tests/shared/unit/domain/usecases/refresh-learning-content-cache_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { refreshLearningContentCache } from '../../../../../src/shared/domain/usecases/refresh-learning-content-cache.js'; | ||
import { expect, sinon } from '../../../../test-helper.js'; | ||
|
||
describe('Unit | Domain | Usecases | Refresh Learning Content Cache', function () { | ||
it('should use repository to schedule reefresh job', async function () { | ||
// given | ||
const lcmsRefreshCacheJob = { schedule: sinon.stub() }; | ||
|
||
// when | ||
await refreshLearningContentCache({ lcmsRefreshCacheJob }); | ||
|
||
// then | ||
expect(lcmsRefreshCacheJob.schedule).to.have.been.calledOnce; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters