Skip to content

Commit

Permalink
tech(orga): getting ke directly, not snapshots, for campaignAssessmen…
Browse files Browse the repository at this point in the history
…tParticipationResult
  • Loading branch information
alicegoarnisson committed Jan 31, 2025
1 parent 0cb19c2 commit 007e707
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ async function _fetchCampaignAssessmentParticipationResultAttributesFromCampaign
}

async function _buildCampaignAssessmentParticipationResults(result, campaignLearningContent) {
const knowledgeElementsGroupedByUser = await knowledgeElementRepository.findSnapshotForUsers({
[result.userId]: result.sharedAt,
const knowledgeElementsGroupedByUser = await knowledgeElementRepository.findAssessedByUserIdAndLimitDateQuery({
userId: result.userId,
limitDate: result.sharedAt,
});
const knowledgeElements = Object.values(knowledgeElementsGroupedByUser).flat();
const validatedTargetedKnowledgeElementsCountByCompetenceId =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function _findByUserIdAndLimitDateQuery({ userId, limitDate, skillIds = [] }) {
});
}

async function _findAssessedByUserIdAndLimitDateQuery({ userId, limitDate, skillIds }) {
async function findAssessedByUserIdAndLimitDateQuery({ userId, limitDate, skillIds }) {
const knowledgeElementRows = await _findByUserIdAndLimitDateQuery({ userId, limitDate, skillIds });

const knowledgeElements = _.map(
Expand All @@ -51,7 +51,7 @@ async function findSnapshotForUsers(userIdsAndDates) {
const userId = parseInt(userIdStr);
let knowledgeElements = knowledgeElementsFromSnapshot;
if (!knowledgeElements) {
knowledgeElements = await _findAssessedByUserIdAndLimitDateQuery({
knowledgeElements = await findAssessedByUserIdAndLimitDateQuery({
userId,
limitDate: userIdsAndDates[userId],
});
Expand All @@ -64,7 +64,7 @@ async function findSnapshotForUsers(userIdsAndDates) {
const findUniqByUserIds = function (userIds) {
return Promise.all(
userIds.map(async (userId) => {
const knowledgeElements = await _findAssessedByUserIdAndLimitDateQuery({
const knowledgeElements = await findAssessedByUserIdAndLimitDateQuery({
userId,
});

Expand All @@ -81,7 +81,7 @@ const batchSave = async function ({ knowledgeElements }) {
};

const findUniqByUserId = function ({ userId, limitDate, skillIds }) {
return _findAssessedByUserIdAndLimitDateQuery({ userId, limitDate, skillIds });
return findAssessedByUserIdAndLimitDateQuery({ userId, limitDate, skillIds });
};

const findUniqByUserIdAndAssessmentId = async function ({ userId, assessmentId }) {
Expand All @@ -96,7 +96,7 @@ const findUniqByUserIdAndAssessmentId = async function ({ userId, assessmentId }
};

const findUniqByUserIdAndCompetenceId = async function ({ userId, competenceId }) {
const knowledgeElements = await _findAssessedByUserIdAndLimitDateQuery({ userId });
const knowledgeElements = await findAssessedByUserIdAndLimitDateQuery({ userId });
return knowledgeElements.filter((knowledgeElement) => knowledgeElement.competenceId === competenceId);
};

Expand Down Expand Up @@ -131,6 +131,7 @@ const findInvalidatedAndDirectByUserId = async function (userId) {

export {
batchSave,
findAssessedByUserIdAndLimitDateQuery,
findInvalidatedAndDirectByUserId,
findSnapshotForUsers,
findUniqByUserId,
Expand Down

0 comments on commit 007e707

Please sign in to comment.