We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 44c0358 commit 670bde9Copy full SHA for 670bde9
backend/PyMatcha/models/notification.py
@@ -20,11 +20,13 @@
20
21
import logging
22
from datetime import datetime
23
+from typing import Dict
24
from typing import Optional
25
26
from PyMatcha.utils import create_notifications_table
27
from PyMatcha.utils.orm import Field
28
from PyMatcha.utils.orm import Model
29
+from timeago import format as timeago_format
30
31
32
class Notification(Model):
@@ -69,3 +71,8 @@ def create(
69
71
@classmethod
70
72
def create_table(cls):
73
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