Skip to content

Commit 8211d7c

Browse files
committed
Back to before
1 parent 7af5b95 commit 8211d7c

File tree

4 files changed

+102
-55
lines changed

4 files changed

+102
-55
lines changed

PyMatchaV2.postman_collection.json

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6653,7 +6653,7 @@
66536653
"",
66546654
"tests[\"success is true\"] = response.success == true",
66556655
"tests[\"Viewed list is empty\"] = response.viewed.length == 1",
6656-
"tests[\"Viewed n1 is correct\"] = response.viewed[0].profile_id == 500"
6656+
"tests[\"Viewed n1 is correct\"] = response.viewed[0].id == 500"
66576657
],
66586658
"type": "text/javascript"
66596659
}
@@ -6736,7 +6736,7 @@
67366736
"",
67376737
"tests[\"success is true\"] = response.success == true",
67386738
"tests[\"Liked list is filled with 1 entry\"] = response.liked.length == 1",
6739-
"tests[\"Liked n1 is correct\"] = response.liked[0].liked_id == 1500"
6739+
"tests[\"Liked n1 is correct\"] = response.liked[0].id == 1500"
67406740
],
67416741
"type": "text/javascript"
67426742
}
@@ -6777,7 +6777,7 @@
67776777
"",
67786778
"tests[\"success is true\"] = response.success == true",
67796779
"tests[\"Liked me list contains one entry\"] = response.liked_me.length == 1",
6780-
"tests[\"Liked me first entry's id is 1500\"] = response.liked_me[0].liker_id == 1500",
6780+
"tests[\"Liked me first entry's id is 1500\"] = response.liked_me[0].id == 1500",
67816781
""
67826782
],
67836783
"type": "text/javascript"
@@ -7230,162 +7230,162 @@
72307230
],
72317231
"variable": [
72327232
{
7233-
"id": "b6341496-7c48-438b-98c0-fcdd30855c18",
7233+
"id": "3e50a45c-f7b6-4503-898e-7a2a319f21c6",
72347234
"key": "host",
72357235
"value": "http://127.0.0.1:5000"
72367236
},
72377237
{
7238-
"id": "84af52b9-2f36-47d5-82d6-9255fa8b8294",
7238+
"id": "df25c64c-7f48-448e-8505-a0b970f3db0c",
72397239
"key": "access_token",
72407240
"value": ""
72417241
},
72427242
{
7243-
"id": "b093ec7e-4a80-4a49-a38d-a3b2a8fdef9c",
7243+
"id": "6b4cdb7c-f052-4235-aba4-300e8ea5a78a",
72447244
"key": "refresh_token",
72457245
"value": ""
72467246
},
72477247
{
7248-
"id": "1a9c0461-06bc-4ea3-9a26-777cb95b3655",
7248+
"id": "02e0ebf1-a832-49eb-a738-7817f6281e58",
72497249
"key": "debug_token",
72507250
"value": "xX69jules69Xx"
72517251
},
72527252
{
7253-
"id": "85111e59-192b-4b22-b7ed-caa8edf44ca4",
7253+
"id": "2dcc1cbe-016f-4cd5-a595-d0a789158d39",
72547254
"key": "id",
72557255
"value": "1541"
72567256
},
72577257
{
7258-
"id": "416bfccb-168f-4f82-972f-61b2be2ca9a9",
7258+
"id": "e8bb8541-cd39-456d-8f8a-6d974982c40b",
72597259
"key": "first_name",
72607260
"value": "Jules"
72617261
},
72627262
{
7263-
"id": "9b873e7a-b7c3-4e6c-8911-2d3a5baf32ca",
7263+
"id": "12ea98a3-1c9f-463d-b820-c9803ae9eaad",
72647264
"key": "last_name",
72657265
"value": "Lasne"
72667266
},
72677267
{
7268-
"id": "14def1f0-3d73-45cd-b888-946e8459e29c",
7268+
"id": "c4335ab4-917c-4b59-9f35-19f9f4476d92",
72697269
"key": "email",
72707270
"value": "jules.lasne@example.org"
72717271
},
72727272
{
7273-
"id": "15f9b561-1128-45a9-9ee9-eb2c68918d8c",
7273+
"id": "6bb86094-ebb6-4795-852a-7aa813c9548a",
72747274
"key": "username",
72757275
"value": "seluj78"
72767276
},
72777277
{
7278-
"id": "ca41ce71-7434-4d42-a892-892ca803dd57",
7278+
"id": "66ad79d0-1da1-4c86-856f-68b8cb9b543f",
72797279
"key": "password",
72807280
"value": "dolphin"
72817281
},
72827282
{
7283-
"id": "d4be1792-c94b-445e-8291-c1cde03e0241",
7283+
"id": "2bfe0b20-7576-406d-925a-76ec05695a56",
72847284
"key": "orientation",
72857285
"value": "heterosexual"
72867286
},
72877287
{
7288-
"id": "55fb2f70-d22a-4d7c-9942-bbc81f88eb70",
7288+
"id": "7e307fe3-ad69-42a4-851e-c6054e88f533",
72897289
"key": "gender",
72907290
"value": "male"
72917291
},
72927292
{
7293-
"id": "1cea974f-4e57-468e-8464-3e854c270269",
7293+
"id": "c30ca7ec-d669-4ca3-8736-9bfdcbb7492c",
72947294
"key": "bio",
72957295
"value": "Phasellus vel tortor vel elit scelerisque accumsan vel nec nunc. Ut condimentum vestibulum sapien non dictum. Vestibulum ac eleifend mi. Curabitur dictum vestibulum ex at placerat. Pellentesque odio mi, condimentum et sollicitudin at, finibus non leo. Aenean sed pulvinar nulla, nec tincidunt felis. Aenean nibh elit, aliquam sit amet lobortis et, pellentesque ut orci. Curabitur placerat sem id ex laoreet imperdiet. Curabitur dictum ac urna feugiat viverra. Vivamus nec pulvinar urna. Suspendisse vel ultrices est. Sed malesuada est vel orci venenatis scelerisque. Phasellus ultrices dignissim sapien, at mattis tellus mattis pulvinar. Sed ut euismod velit, id fermentum leo."
72967296
},
72977297
{
7298-
"id": "ad0b3387-49eb-42a7-899c-c9576360e7d0",
7298+
"id": "5df95083-a02d-42cc-adca-af2fc7f4a931",
72997299
"key": "birthdate",
73007300
"value": "06/04/1998"
73017301
},
73027302
{
7303-
"id": "c5e923ac-9341-4f98-b1fe-21273f8abc66",
7303+
"id": "95044a57-47d6-4de8-85f1-7263e0341f79",
73047304
"key": "first_name2",
73057305
"value": "Félix"
73067306
},
73077307
{
7308-
"id": "f2bdb825-5157-4ca5-858f-ad43c226a231",
7308+
"id": "d2aae104-3ac8-435d-b506-9085c84dbdad",
73097309
"key": "last_name2",
73107310
"value": "Ensal"
73117311
},
73127312
{
7313-
"id": "4a4e5470-6c89-4d62-b7bd-b90713ec3b8f",
7313+
"id": "b6ff9c48-4fe5-4801-8349-7fdc764bf394",
73147314
"key": "username2",
73157315
"value": "Ufree"
73167316
},
73177317
{
7318-
"id": "d3440bfb-3f0b-437e-a992-78ab2ded5af8",
7318+
"id": "9d9fb357-9866-4da3-bfff-cec077624a25",
73197319
"key": "bio2",
73207320
"value": "Donec quis porttitor ante, ac pulvinar nulla. Vivamus dignissim, ipsum ultricies interdum suscipit, risus tellus auctor mi, eu auctor metus sem quis urna. In maximus placerat ipsum, nec sodales elit aliquet sed. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Phasellus malesuada velit felis, non volutpat ex bibendum at. Maecenas aliquet sodales quam at consequat. Sed faucibus consequat tempor. Fusce consequat eu sem non tempus. Duis dapibus nunc vel tempus semper. Pellentesque dignissim tellus odio, vel luctus ipsum suscipit quis. Curabitur id erat at quam varius fermentum non in massa."
73217321
},
73227322
{
7323-
"id": "5e1bdaab-4dca-4486-b824-d47d4b8bc9b2",
7323+
"id": "3ad12943-7b1f-481f-b5a2-ead7d6402a58",
73247324
"key": "gender2",
73257325
"value": "other"
73267326
},
73277327
{
7328-
"id": "6cc98929-2c3e-436a-9106-84c55312144b",
7328+
"id": "f55b25d0-b708-47bd-a10f-922cb7b4f211",
73297329
"key": "orientation2",
73307330
"value": "bisexual"
73317331
},
73327332
{
7333-
"id": "750b1524-9246-4711-a27b-b529fe015ca1",
7333+
"id": "6f90d87b-f468-4417-9481-2102220b89b0",
73347334
"key": "birthdate2",
73357335
"value": "25/06/2000"
73367336
},
73377337
{
7338-
"id": "a795c593-e13a-4def-a93a-ad90d8ba06bb",
7338+
"id": "88b302d8-8018-457d-ae33-2ce511e3d4f5",
73397339
"key": "email2",
73407340
"value": "felix.ensal@example.org"
73417341
},
73427342
{
7343-
"id": "247a8baf-80e6-473f-8fed-1184e7003a93",
7343+
"id": "7e4aeab9-c234-4ee1-8d0c-0e30c12b79ea",
73447344
"key": "password2",
73457345
"value": "dolphin2"
73467346
},
73477347
{
7348-
"id": "695ba1e9-3ed0-44e1-8ece-6db34cade403",
7348+
"id": "95f78452-7269-45f9-9202-879adc7feb60",
73497349
"key": "ip",
73507350
"value": "90.108.46.63"
73517351
},
73527352
{
7353-
"id": "8057ac3e-51f0-4fb8-b21e-408dc6abc368",
7353+
"id": "f8e0b102-6fa0-405c-b684-ed2976662d36",
73547354
"key": "lat",
73557355
"value": "49.5271"
73567356
},
73577357
{
7358-
"id": "68c1db67-17b2-457a-87d6-ea9d9baa0cc5",
7358+
"id": "d088bed1-37fe-4edc-9110-5a6c1fdadb78",
73597359
"key": "lng",
73607360
"value": "1.1885"
73617361
},
73627362
{
7363-
"id": "a6b45d71-5d59-4402-a261-d7eb6004135e",
7363+
"id": "f02f943b-b835-46ea-8f92-ec51ad160ed0",
73647364
"key": "my_msg_id",
73657365
"value": "-1"
73667366
},
73677367
{
7368-
"id": "bdb184b2-8746-44a7-8554-00b145d7e7bc",
7368+
"id": "a5380797-19c0-4b69-8632-d7eac317ed6e",
73697369
"key": "to_me_msg_id",
73707370
"value": "-1"
73717371
},
73727372
{
7373-
"id": "0afe5f85-c0f2-441c-8669-564f06af6ad0",
7373+
"id": "7455c588-11dd-455d-b0d6-e9d1b051e0c9",
73747374
"key": "other_msg_id",
73757375
"value": "-1"
73767376
},
73777377
{
7378-
"id": "e72532bb-b979-45d1-a259-9dd0ebe0d7ec",
7378+
"id": "4ec2e211-56dc-4c5a-8fa5-1bd65a276129",
73797379
"key": "user_access_token",
73807380
"value": ""
73817381
},
73827382
{
7383-
"id": "d7c521e0-93fc-499f-a5b7-c58c579882f0",
7383+
"id": "2f59a635-bacd-4d08-ad0d-44b3169b33d1",
73847384
"key": "user_refresh_token",
73857385
"value": ""
73867386
},
73877387
{
7388-
"id": "67ff209d-04d1-4d94-9300-830373299eac",
7388+
"id": "f674942a-f096-4139-9947-02af7849a610",
73897389
"key": "notif_id",
73907390
"value": ""
73917391
}

backend/PyMatcha/routes/api/history.py

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
PyMatcha - A Python Dating Website
33
Copyright (C) 2018-2019 jlasne/gmorer
44
<jlasne@student.42.fr> - <lauris.skraucis@gmail.com>
5-
65
This program is free software: you can redistribute it and/or modify
76
it under the terms of the GNU General Public License as published by
87
the Free Software Foundation, either version 3 of the License, or
98
(at your option) any later version.
10-
119
This program is distributed in the hope that it will be useful,
1210
but WITHOUT ANY WARRANTY; without even the implied warranty of
1311
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1412
GNU General Public License for more details.
15-
1613
You should have received a copy of the GNU General Public License
1714
along with this program. If not, see <https://www.gnu.org/licenses/>.
1815
"""
1916
from flask import Blueprint
2017
from flask import current_app
2118
from flask_jwt_extended import current_user
2219
from flask_jwt_extended import jwt_required
20+
from PyMatcha.models.user import User
21+
from PyMatcha.utils.match_score import _get_common_tags
22+
from PyMatcha.utils.match_score import _get_distance
2323
from PyMatcha.utils.success import SuccessOutput
2424

2525

@@ -29,38 +29,93 @@
2929
@history_bp.route("/history/viewed")
3030
@jwt_required
3131
def history_viewed_people():
32-
viewed = [view.to_dict() for view in current_user.get_view_history()]
32+
views = current_user.get_view_history()
33+
viewed_people = []
34+
for view in views:
35+
user = User.get(id=view.profile_id)
36+
distance = _get_distance(current_user.geohash, user.geohash)
37+
user_tags = [t.name for t in user.get_tags()]
38+
current_user_tags = [t.name for t in current_user.get_tags()]
39+
common_tags = _get_common_tags(current_user_tags, user_tags)
40+
user_dict = user.to_dict()
41+
user_dict["common_tags"] = common_tags
42+
user_dict["distance"] = distance
43+
viewed_people.append(user_dict)
3344
current_app.logger.info(f"Returning viewed profiles for user {current_user.id}")
34-
return SuccessOutput("viewed", viewed)
45+
return SuccessOutput("viewed", viewed_people)
3546

3647

3748
@history_bp.route("/history/viewed/me", methods=["GET"])
3849
@jwt_required
3950
def history_viewed_me():
40-
viewed_people = [view.to_dict() for view in current_user.get_views()]
51+
views = current_user.get_views()
52+
viewed_people = []
53+
for view in views:
54+
user = User.get(id=view.viewer_id)
55+
distance = _get_distance(current_user.geohash, user.geohash)
56+
user_tags = [t.name for t in user.get_tags()]
57+
current_user_tags = [t.name for t in current_user.get_tags()]
58+
common_tags = _get_common_tags(current_user_tags, user_tags)
59+
user_dict = user.to_dict()
60+
user_dict["common_tags"] = common_tags
61+
user_dict["distance"] = distance
62+
viewed_people.append(user_dict)
4163
current_app.logger.info(f"Returning profiles who viewed user {current_user.id}")
4264
return SuccessOutput("viewed_me", viewed_people)
4365

4466

4567
@history_bp.route("/history/liked", methods=["GET"])
4668
@jwt_required
4769
def history_liked_people():
48-
liked = [like.to_dict() for like in current_user.get_likes_sent()]
70+
likes = current_user.get_likes_sent()
71+
liked_people = []
72+
for like in likes:
73+
user = User.get(id=like.liked_id)
74+
distance = _get_distance(current_user.geohash, user.geohash)
75+
user_tags = [t.name for t in user.get_tags()]
76+
current_user_tags = [t.name for t in current_user.get_tags()]
77+
common_tags = _get_common_tags(current_user_tags, user_tags)
78+
user_dict = user.to_dict()
79+
user_dict["common_tags"] = common_tags
80+
user_dict["distance"] = distance
81+
liked_people.append(user_dict)
4982
current_app.logger.info(f"Returning liked profiles for user {current_user.id}")
50-
return SuccessOutput("liked", liked)
83+
return SuccessOutput("liked", liked_people)
5184

5285

5386
@history_bp.route("/history/liked/me", methods=["GET"])
5487
@jwt_required
5588
def history_liked_me():
56-
liked_people = [like.to_dict() for like in current_user.get_likes_received()]
89+
likes = current_user.get_likes_received()
90+
liked_people = []
91+
for like in likes:
92+
user = User.get(id=like.liker_id)
93+
distance = _get_distance(current_user.geohash, user.geohash)
94+
user_tags = [t.name for t in user.get_tags()]
95+
current_user_tags = [t.name for t in current_user.get_tags()]
96+
common_tags = _get_common_tags(current_user_tags, user_tags)
97+
user_dict = user.to_dict()
98+
user_dict["common_tags"] = common_tags
99+
user_dict["distance"] = distance
100+
liked_people.append(user_dict)
57101
current_app.logger.info(f"Returning profiles who liked user {current_user.id}")
58102
return SuccessOutput("liked_me", liked_people)
59103

60104

61105
@history_bp.route("/history/blocked", methods=["GET"])
62106
@jwt_required
63107
def history_blocked():
64-
blocked_people = [block.to_dict() for block in current_user.get_blocks()]
108+
blocks = current_user.get_blocks()
109+
blocked_people = []
110+
for block in blocks:
111+
user = User.get(id=block.blocked_id)
112+
distance = _get_distance(current_user.geohash, user.geohash)
113+
user_tags = [t.name for t in user.get_tags()]
114+
current_user_tags = [t.name for t in current_user.get_tags()]
115+
common_tags = _get_common_tags(current_user_tags, user_tags)
116+
user_dict = user.to_dict()
117+
user_dict["common_tags"] = common_tags
118+
user_dict["distance"] = distance
119+
blocked_people.append(user_dict)
65120
current_app.logger.info(f"Returning blocked profiles for user {current_user.id}")
66121
return SuccessOutput("blocked", blocked_people)

backend/PyMatcha/routes/api/user.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
from flask import Blueprint
2020
from flask import current_app
2121
from flask import jsonify
22-
from flask_jwt_extended import current_user
2322
from flask_jwt_extended import jwt_required
2423
from PyMatcha.models.user import get_user
2524
from PyMatcha.models.user import User
2625
from PyMatcha.utils.errors import NotFoundError
27-
from PyMatcha.utils.match_score import _get_common_tags
28-
from PyMatcha.utils.match_score import _get_distance
2926

3027
user_bp = Blueprint("user", __name__)
3128

@@ -49,12 +46,7 @@ def get_one_user(uid):
4946
pass
5047
else:
5148
current_app.logger.info(f"Returning info on user {uid}")
52-
returned_dict = u.to_dict()
53-
user_tags = [t.name for t in u.get_tags()]
54-
current_user_tags = [t.name for t in current_user.get_tags()]
55-
returned_dict["distance"] = _get_distance(current_user.geohash, u.geohash)
56-
returned_dict["common_tags"] = _get_common_tags(current_user_tags, user_tags)
57-
return jsonify(returned_dict)
49+
return jsonify(u.to_dict())
5850

5951

6052
@user_bp.route("/users/online", methods=["GET"])

backend/PyMatcha/utils/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def setup_periodic_tasks(sender, **kwargs):
3232
sender.add_periodic_task(
3333
600, calc_search_min_max.s(), name="Update Minimum and Maximum scores and ages for search every 10 minutes"
3434
)
35-
sender.add_periodic_task(10, random_bot_action.s(), name="Bots will do random actions")
35+
sender.add_periodic_task(180, random_bot_action.s(), name="Bots will do random actions")
3636

3737

3838
@celery.task

0 commit comments

Comments
 (0)