Skip to content

Commit 1f22a08

Browse files
committed
Added recommendations
1 parent 033209c commit 1f22a08

File tree

3 files changed

+133
-4
lines changed

3 files changed

+133
-4
lines changed

backend/PyMatcha/routes/api/recommendations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
You should have received a copy of the GNU General Public License
1717
along with this program. If not, see <https://www.gnu.org/licenses/>.
1818
"""
19+
import json
20+
1921
from flask import Blueprint
2022
from flask_jwt_extended import current_user
2123
from flask_jwt_extended import jwt_required
@@ -32,4 +34,4 @@ def get_recommendations():
3234
recommendations = redis.get(f"user_recommendations:{str(current_user.id)}")
3335
if not recommendations:
3436
raise NotFoundError("Recommendations not calculated yet", "Please come back later")
35-
return SuccessOutput("recommendations", recommendations)
37+
return SuccessOutput("recommendations", json.loads(recommendations))

backend/PyMatcha/utils/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def update_user_recommendations():
107107
for user_to_update in User.select_all():
108108
count += 1
109109
user_to_update_recommendations = []
110-
110+
# TODO: Find a way to bypass that
111111
if not user_to_update.birthdate:
112112
continue
113113
if not user_to_update.geohash:

backend/schemas/swagger.yaml

Lines changed: 129 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,34 @@ paths:
762762
type: array
763763
items:
764764
$ref: '#/components/schemas/UnseenMessage'
765+
/recommendations:
766+
get:
767+
summary: Get user recommendations
768+
operationId: getRecommendations
769+
tags:
770+
- Recommendations
771+
responses:
772+
"404":
773+
$ref: '#/components/responses/NotFound'
774+
"200":
775+
description: Returns a list of recommendations
776+
content:
777+
application/json:
778+
schema:
779+
type: object
780+
properties:
781+
success:
782+
type: boolean
783+
description: If the request is a success
784+
example: true
785+
code:
786+
type: integer
787+
description: The status code
788+
example: 200
789+
recommendations:
790+
type: array
791+
items:
792+
$ref: '#/components/schemas/Recommendation'
765793

766794

767795
servers:
@@ -997,7 +1025,7 @@ components:
9971025
type: object
9981026
properties:
9991027
id:
1000-
type: integeer
1028+
type: integer
10011029
example: 1
10021030
first_name:
10031031
type: string
@@ -1305,4 +1333,103 @@ components:
13051333
to_user:
13061334
type: string
13071335
example: 1
1308-
description: The user id who received the message
1336+
description: The user id who received the message
1337+
# TODO: Add descriptions
1338+
Recommendation:
1339+
type: object
1340+
properties:
1341+
score:
1342+
type: integer
1343+
example: 10
1344+
description: A score to sort the recommendations by. The higher the closest the match. Score can be negative
1345+
common_tags:
1346+
type: array
1347+
example: [ "friends", "drinks", "sun" ]
1348+
distance:
1349+
type: integer
1350+
example: 50
1351+
description: The distance between two users
1352+
id:
1353+
type: integer
1354+
example: 1
1355+
first_name:
1356+
type: string
1357+
example: Foo
1358+
last_name:
1359+
type: string
1360+
example: Bar
1361+
username:
1362+
type: string
1363+
example: FooBar
1364+
email:
1365+
type: string
1366+
example: foo@example.org
1367+
bio:
1368+
type: string
1369+
example: Lorem Ipsum is the single greatest threat. We are not - we are not keeping up with other websites. Lorem Ipsum best not make any more threats to your website. It will be met with fire and fury like the world has never seen. Does everybody know that pig named Lorem Ipsum? An ‘extremely credible source’ has called my office and told me that Barack Obama’s placeholder text is a fraud.
1370+
birthdate:
1371+
type: date
1372+
example: Mon, 06 Apr 1998 00:00:00 GMT
1373+
gender:
1374+
type: string
1375+
enum: ["male", "female", "other"]
1376+
example: male
1377+
orientation:
1378+
type: string
1379+
enum: [ "heterosexual", "homosexual", "bisexual", "other" ]
1380+
example: heterosexual
1381+
geohash:
1382+
type: string
1383+
example: u09whv25xgzn
1384+
heat_score:
1385+
type: integer
1386+
example: 123
1387+
confirmed_on:
1388+
type: date
1389+
example: Wed, 16 Sep 2020 15:20:02 GMT
1390+
date_joined:
1391+
type: date
1392+
example: Wed, 16 Sep 2020 15:18:02 GMT
1393+
date_lastseen:
1394+
type: date
1395+
example: Wed, 19 Sep 2020 19:24:02 GMT
1396+
is_confirmed:
1397+
type: boolean
1398+
example: true
1399+
is_online:
1400+
type: boolean
1401+
example: true
1402+
is_profile_completed:
1403+
type: boolean
1404+
example: true
1405+
likes:
1406+
type: object
1407+
properties:
1408+
sent:
1409+
type: array
1410+
items:
1411+
$ref: '#/components/schemas/Like'
1412+
uniqueItems: true
1413+
received:
1414+
type: array
1415+
items:
1416+
$ref: '#/components/schemas/Like'
1417+
uniqueItems: true
1418+
reports:
1419+
type: object
1420+
properties:
1421+
sent:
1422+
type: array
1423+
items:
1424+
$ref: '#/components/schemas/Report'
1425+
uniqueItems: true
1426+
received:
1427+
type: array
1428+
items:
1429+
$ref: '#/components/schemas/Report'
1430+
uniqueItems: true
1431+
tags:
1432+
type: array
1433+
items:
1434+
$ref: '#/components/schemas/Tag'
1435+
uniqueItems: true

0 commit comments

Comments
 (0)