Skip to content

Commit 2f35765

Browse files
committed
floor distance of each recommendations and save tag names as interests array
1 parent af606d3 commit 2f35765

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

frontend/src/views/app/Browse.vue

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Recommendations
77
v-if="recommendationsAnalysisDone"
88
v-bind:title="'Potential matches'"
9-
v-bind:recommendations="recommendations"
9+
v-bind:recommendationsReceived="recommendations"
1010
v-bind:recommendationsAnalysis="recommendationsAnalysis"></Recommendations>
1111
</section>
1212
</div>
@@ -42,16 +42,6 @@ export default {
4242
},
4343
recommendationsAnalysisDone: false,
4444
}),
45-
methods: {
46-
interestsIdsOfUser(user) {
47-
const interestsIds = [];
48-
const interestObjects = user.tags;
49-
for (let i = 0; i < interestObjects.length; i += 1) {
50-
interestsIds.push(interestObjects[i].id);
51-
}
52-
return interestsIds;
53-
},
54-
},
5545
async created() {
5646
if (this.recommendationsFromSettingUp) {
5747
this.recommendations = this.recommendationsFromSettingUp;
@@ -61,17 +51,18 @@ export default {
6151
}
6252
this.recommendations.sort((a, b) => a.distance - b.distance);
6353
for (let i = 0; i < this.recommendations.length; i += 1) {
54+
this.recommendations[i].distance = Math.floor(this.recommendations[i].distance);
6455
if (this.recommendationsAnalysis.age.min === null || this.recommendations[i].age < this.recommendationsAnalysis.age.min) {
6556
this.recommendationsAnalysis.age.min = this.recommendations[i].age;
6657
}
6758
if (this.recommendationsAnalysis.age.max === null || this.recommendations[i].age > this.recommendationsAnalysis.age.max) {
6859
this.recommendationsAnalysis.age.max = this.recommendations[i].age;
6960
}
70-
if (this.recommendationsAnalysis.distance.min === null || Math.floor(this.recommendations[i].distance) < this.recommendationsAnalysis.distance.min) {
71-
this.recommendationsAnalysis.distance.min = Math.floor(this.recommendations[i].distance);
61+
if (this.recommendationsAnalysis.distance.min === null || this.recommendations[i].distance < this.recommendationsAnalysis.distance.min) {
62+
this.recommendationsAnalysis.distance.min = this.recommendations[i].distance;
7263
}
73-
if (this.recommendationsAnalysis.distance.max === null || Math.floor(this.recommendations[i].distance) > this.recommendationsAnalysis.distance.max) {
74-
this.recommendationsAnalysis.distance.max = Math.floor(this.recommendations[i].distance);
64+
if (this.recommendationsAnalysis.distance.max === null || this.recommendations[i].distance > this.recommendationsAnalysis.distance.max) {
65+
this.recommendationsAnalysis.distance.max = this.recommendations[i].distance;
7566
}
7667
if (this.recommendationsAnalysis.popularity.min === null || this.recommendations[i].heat_score < this.recommendationsAnalysis.popularity.min) {
7768
this.recommendationsAnalysis.popularity.min = this.recommendations[i].heat_score;
@@ -80,15 +71,12 @@ export default {
8071
this.recommendationsAnalysis.popularity.max = this.recommendations[i].heat_score;
8172
}
8273
const interests = this.recommendations[i].tags;
83-
const interestsIdsOfLoggedInUser = this.interestsIdsOfUser(this.$store.getters.getLoggedInUser);
84-
this.recommendations[i].common_interests = 0;
74+
this.recommendations[i].interests = [];
8575
for (let j = 0; j < interests.length; j += 1) {
76+
this.recommendations[i].interests.push(interests[j].name);
8677
if (this.recommendationsAnalysis.uniqueInterests.indexOf(interests[j].name) === -1) {
8778
this.recommendationsAnalysis.uniqueInterests.push(interests[j].name);
8879
}
89-
if (interestsIdsOfLoggedInUser.indexOf(interests[j].id) !== -1) {
90-
this.recommendations[i].common_interests += 1;
91-
}
9280
}
9381
}
9482
this.recommendationsAnalysisDone = true;

0 commit comments

Comments
 (0)