From 435905101cf77e00f2faf73c9bc13151423bd722 Mon Sep 17 00:00:00 2001 From: Robert Raposa Date: Mon, 12 Sep 2016 10:25:09 -0400 Subject: [PATCH] Cache comment thread. --- lms/lib/comment_client/comment.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lms/lib/comment_client/comment.py b/lms/lib/comment_client/comment.py index ae6f89921c..76f200f9f4 100644 --- a/lms/lib/comment_client/comment.py +++ b/lms/lib/comment_client/comment.py @@ -27,9 +27,15 @@ class Comment(models.Model): base_url = "{prefix}/comments".format(prefix=settings.PREFIX) type = 'comment' + def __init__(self, *args, **kwargs): + super(Comment, self).__init__(*args, **kwargs) + self._cached_thread = None + @property def thread(self): - return Thread(id=self.thread_id, type='thread') + if not self._cached_thread: + self._cached_thread = Thread(id=self.thread_id, type='thread') + return self._cached_thread @property def context(self):