Skip to content

Commit 3638674

Browse files
authored
Merge pull request #300 from Seluj78/feature/298-ignore-matched-users
Added ignoring of matched and liked users
2 parents 434fe13 + ee8f7a8 commit 3638674

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

backend/PyMatcha/routes/api/search.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,15 @@ def search():
3838
today = datetime.datetime.utcnow()
3939

4040
query = _get_gender_query(current_user.orientation, current_user.gender)
41+
matches_id = [match.id for match in current_user.get_matches()]
42+
likes_sent_user_ids = [like.liked_id for like in current_user.get_likes_sent()]
4143
returned_list = []
4244
for user in query:
45+
if user.id == current_user.id:
46+
continue
47+
if user.id in matches_id or user.id in likes_sent_user_ids:
48+
continue
49+
4350
user_age = (
4451
today.year - user.birthdate.year - ((today.month, today.day) < (user.birthdate.month, user.birthdate.day))
4552
)

backend/PyMatcha/utils/recommendations.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ def create_user_recommendations(user_to_update):
3232

3333
if not query:
3434
return
35+
36+
matches_id = [match.id for match in user_to_update.get_matches()]
37+
likes_sent_user_ids = [like.liked_id for like in user_to_update.get_likes_sent()]
38+
3539
for user in query:
3640
if user.id == user_to_update.id:
3741
continue
42+
if user.id in matches_id or user.id in likes_sent_user_ids:
43+
continue
3844
score = 0
3945

4046
distance = _get_distance(user_to_update.geohash, user.geohash)

0 commit comments

Comments
 (0)