|
9 | 9 | import { PrismaService } from 'src/prisma.service'; |
10 | 10 | import { |
11 | 11 | getPairwiseCombinations, |
12 | | - sortCombinationsByImplicitCategory, |
| 12 | + sortCombinationsByImplicitCategoryAndOccurance, |
13 | 13 | } from 'src/utils'; |
14 | 14 | import { |
15 | 15 | generateZeroMatrix, |
@@ -744,29 +744,30 @@ export class FlowService { |
744 | 744 | const getProjectImplicitCatById = (id: number) => |
745 | 745 | allProjects.find((el) => el.id === id)?.implicitCategory || ''; |
746 | 746 |
|
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 | + ); |
751 | 751 |
|
752 | 752 | const allIds = allProjects.map((child) => child.id); |
753 | 753 |
|
754 | | - // const projectIdOccurencesRanking = this.determineIdRanking(votedIds); |
| 754 | + const projectIdOccurencesRanking = this.determineIdRanking(votedIds); |
755 | 755 |
|
756 | 756 | // ascending id rankings (i.e., the last element has been voted the most) |
757 | | - // let idRanking: number[] = []; |
| 757 | + let idRanking: number[] = []; |
758 | 758 |
|
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 | + } |
763 | 763 |
|
764 | | - // idRanking = [...idRanking, ...projectIdOccurencesRanking]; |
| 764 | + idRanking = [...idRanking, ...projectIdOccurencesRanking]; |
765 | 765 |
|
766 | 766 | const combinations = getPairwiseCombinations(allIds); |
767 | 767 |
|
768 | | - const sortedCombinations = sortCombinationsByImplicitCategory( |
| 768 | + const sortedCombinations = sortCombinationsByImplicitCategoryAndOccurance( |
769 | 769 | combinations, |
| 770 | + idRanking, |
770 | 771 | getProjectImplicitCatById, |
771 | 772 | ); |
772 | 773 |
|
|
0 commit comments