Skip to content

Commit 6ac5026

Browse files
committed
Tweaking pair ordering algo
1 parent 73892fe commit 6ac5026

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/flow/flow.service.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import { PrismaService } from 'src/prisma.service';
1010
import {
1111
getPairwiseCombinations,
12-
sortCombinationsByImplicitCategory,
12+
sortCombinationsByImplicitCategoryAndOccurance,
1313
} from 'src/utils';
1414
import {
1515
generateZeroMatrix,
@@ -744,29 +744,30 @@ export class FlowService {
744744
const getProjectImplicitCatById = (id: number) =>
745745
allProjects.find((el) => el.id === id)?.implicitCategory || '';
746746

747-
// const votedIds = allVotes.reduce(
748-
// (acc, vote) => [...acc, vote.project1Id, vote.project2Id],
749-
// [] as number[],
750-
// );
747+
const votedIds = allVotes.reduce(
748+
(acc, vote) => [...acc, vote.project1Id, vote.project2Id],
749+
[] as number[],
750+
);
751751

752752
const allIds = allProjects.map((child) => child.id);
753753

754-
// const projectIdOccurencesRanking = this.determineIdRanking(votedIds);
754+
const projectIdOccurencesRanking = this.determineIdRanking(votedIds);
755755

756756
// ascending id rankings (i.e., the last element has been voted the most)
757-
// let idRanking: number[] = [];
757+
let idRanking: number[] = [];
758758

759-
// for (let i = 0; i < allIds.length; i++) {
760-
// const value = allIds[i];
761-
// if (!projectIdOccurencesRanking.includes(value)) idRanking.push(value);
762-
// }
759+
for (let i = 0; i < allIds.length; i++) {
760+
const value = allIds[i];
761+
if (!projectIdOccurencesRanking.includes(value)) idRanking.push(value);
762+
}
763763

764-
// idRanking = [...idRanking, ...projectIdOccurencesRanking];
764+
idRanking = [...idRanking, ...projectIdOccurencesRanking];
765765

766766
const combinations = getPairwiseCombinations(allIds);
767767

768-
const sortedCombinations = sortCombinationsByImplicitCategory(
768+
const sortedCombinations = sortCombinationsByImplicitCategoryAndOccurance(
769769
combinations,
770+
idRanking,
770771
getProjectImplicitCatById,
771772
);
772773

0 commit comments

Comments
 (0)