-
Notifications
You must be signed in to change notification settings - Fork 57
[TECH] arrêter d'utiliser les champs userId / snappedAt (Pix-17286) #11965
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
Changes from all commits
a05bf9c
2368b78
0f202fb
e9545ba
892ed12
492183e
20bdd51
3cb42c5
36b3db5
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 |
---|---|---|
|
@@ -7,24 +7,20 @@ import { buildUser } from './build-user.js'; | |
|
||
const buildKnowledgeElementSnapshot = function ({ | ||
id = databaseBuffer.getNextId(), | ||
userId, | ||
snappedAt = new Date('2020-01-01'), | ||
snapshot, | ||
campaignParticipationId, | ||
userId, | ||
} = {}) { | ||
const dateMinusOneDay = new Date(snappedAt.getTime() - 1000 * 60 * 60 * 24 * 7); | ||
userId = _.isUndefined(userId) ? buildUser().id : userId; | ||
if (!snapshot) { | ||
const knowledgeElements = []; | ||
knowledgeElements.push(buildKnowledgeElement({ userId, createdAt: dateMinusOneDay })); | ||
knowledgeElements.push(buildKnowledgeElement({ userId, createdAt: dateMinusOneDay })); | ||
userId = _.isUndefined(userId) ? buildUser().id : userId; | ||
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. thought : avons nous besoin de lodash pour des questions de lisibilité ou est ce que l'écriture |
||
knowledgeElements.push(buildKnowledgeElement({ userId, createdAt: new Date('2020-01-01') })); | ||
knowledgeElements.push(buildKnowledgeElement({ userId, createdAt: new Date('2020-01-01') })); | ||
snapshot = new KnowledgeElementCollection(knowledgeElements).toSnapshot(); | ||
} | ||
|
||
const values = { | ||
id, | ||
userId, | ||
snappedAt, | ||
snapshot, | ||
campaignParticipationId, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,21 +46,17 @@ function _validateAndNormalizeArgs({ concurrency, maxSnapshotCount }) { | |
|
||
async function getEligibleCampaignParticipations(maxSnapshotCount) { | ||
return knex('campaign-participations') | ||
.select('campaign-participations.userId', 'campaign-participations.sharedAt', 'campaign-participations.id') | ||
.leftJoin('knowledge-element-snapshots', function () { | ||
this.on('knowledge-element-snapshots.userId', 'campaign-participations.userId').andOn( | ||
'knowledge-element-snapshots.snappedAt', | ||
'campaign-participations.sharedAt', | ||
); | ||
}) | ||
.select('campaign-participations.id', 'campaign-participations.userId', 'campaign-participations.sharedAt') | ||
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 Est ce qu'on a encore besoin de ce script (on pourrait le supprimer si il n'est plus utile)? 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. Je crois qu'on l'a laissé parce qu'il pourrait nous resservir |
||
.leftJoin( | ||
'knowledge-element-snapshots', | ||
'knowledge-element-snapshots.campaignParticipationId', | ||
'campaign-participations.id', | ||
) | ||
.whereNotNull('campaign-participations.sharedAt') | ||
.where((qb) => { | ||
qb.whereNull('knowledge-element-snapshots.snappedAt').orWhereRaw('?? != ??', [ | ||
'campaign-participations.sharedAt', | ||
'knowledge-element-snapshots.snappedAt', | ||
]); | ||
qb.whereNull('knowledge-element-snapshots.campaignParticipationId'); | ||
}) | ||
.orderBy('campaign-participations.userId') | ||
.orderBy('campaign-participations.id') | ||
.limit(maxSnapshotCount); | ||
} | ||
|
||
|
@@ -79,8 +75,6 @@ async function generateKnowledgeElementSnapshots( | |
}); | ||
try { | ||
await dependencies.knowledgeElementSnapshotRepository.save({ | ||
userId, | ||
snappedAt: sharedAt, | ||
snapshot: new KnowledgeElementCollection(knowledgeElements).toSnapshot(), | ||
campaignParticipationId: id, | ||
}); | ||
|
This file was deleted.
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.
thought: on peut conserver le userId pour la construction des knowledgeElement