Skip to content

Commit 670bde9

Browse files
committed
Added timeago format for notifications
1 parent 44c0358 commit 670bde9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

backend/PyMatcha/models/notification.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020

2121
import logging
2222
from datetime import datetime
23+
from typing import Dict
2324
from typing import Optional
2425

2526
from PyMatcha.utils import create_notifications_table
2627
from PyMatcha.utils.orm import Field
2728
from PyMatcha.utils.orm import Model
29+
from timeago import format as timeago_format
2830

2931

3032
class Notification(Model):
@@ -69,3 +71,8 @@ def create(
6971
@classmethod
7072
def create_table(cls):
7173
create_notifications_table(cls.db)
74+
75+
def to_dict(self) -> Dict:
76+
returned_dict = super().to_dict()
77+
returned_dict["dt_received_ago"] = timeago_format(self.dt_received, datetime.utcnow())
78+
return returned_dict

0 commit comments

Comments
 (0)