Skip to content

Commit b905810

Browse files
committed
Added age as a return thing for the user
1 parent bfeac7a commit b905810

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

backend/PyMatcha/models/user.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ def to_dict(self) -> Dict:
192192
returned_dict["likes"]["received"] = [like.to_dict() for like in self.get_likes_received()]
193193
returned_dict.pop("password")
194194
returned_dict.pop("previous_reset_token")
195+
196+
today = datetime.datetime.utcnow()
197+
returned_dict["age"] = (
198+
today.year - self.birthdate.year - ((today.month, today.day) < (self.birthdate.month, self.birthdate.day))
199+
)
195200
return returned_dict
196201

197202
@classmethod

backend/schemas/swagger.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,9 @@ components:
14901490
is_profile_completed:
14911491
type: boolean
14921492
example: true
1493+
age:
1494+
type: int
1495+
example: 22
14931496
likes:
14941497
type: object
14951498
properties:
@@ -1819,6 +1822,9 @@ components:
18191822
is_profile_completed:
18201823
type: boolean
18211824
example: true
1825+
age:
1826+
type: int
1827+
example: 22
18221828
likes:
18231829
type: object
18241830
properties:

0 commit comments

Comments
 (0)