-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGFIX] Rafraichir le cache LCMS en asynchrone (pgboss) #9422
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 }; |
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Il n'y a pas de propriété statique There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C'est JobPgBoss qui stocke la variable, dans le super de There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nlepage c'est pas une propriété de There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En Javascript, la propriété statique class LcmsRefreshCacheJob {}
console.log(LcmsRefreshCacheJob.name) // returns 'LcmsRefreshCacheJob' Ce qui n'est pas top c'est qu'on initialise également une propriété class LcmsRefreshCacheJob extends JobPgBoss {
constructor(queryBuilder) {
super({ name: 'LcmsRefreshCacheJob', retryLimit: 0 }, queryBuilder);
}
} Ça serait potentiellement un point à améliorer pour l'équipe "Évènementiel" des tech days. |
||
} | ||
} | ||
|
||
export { LcmsRefreshCacheJobHandler }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const refreshLearningContentCache = async function ({ lcmsRefreshCacheJob }) { | ||
await lcmsRefreshCacheJob.schedule(); | ||
}; | ||
export { refreshLearningContentCache }; |
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; | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pourquoi on fait pas de la "vraie" inversion de dépendance ici ? (en déclarant les usecases en argument du controller)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dans tous les controllers de Pix API, on importe les usecases en dépendance node il me semble. Aujourd'hui il n'y a que les serializers injecté en argument des controlleurs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
il y a des exemples dans le code où les usecases sont injectés
https://github.com/1024pix/pix/blob/dev/api/src/devcomp/application/modules/controller.js
https://github.com/1024pix/pix/blob/dev/api/src/devcomp/application/passages/controller.js
mais oui après avoir checké j'ai l'impression qu'on fait ça seulement chez devcomp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ^^ Injecter les usecases comme le reste me semble bien vis-à-vis de notre archi, peut-être qu'on devrait avoir une guideline globale là-dessus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En fait l'ADR 46 dit bien que c'est une volonté de ne pas injecter les usecases dans les controller mais ce n'est pas dit pourquoi (@frinyvonnick ?)