From ffd89c2330b142757a35e2573891c291a1077d4a Mon Sep 17 00:00:00 2001 From: Tibet Sprague Date: Thu, 8 Apr 2021 11:33:29 -0700 Subject: [PATCH] Fix email digests --- api/models/Group.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/models/Group.js b/api/models/Group.js index 5f89fb591..7f5ff5b55 100644 --- a/api/models/Group.js +++ b/api/models/Group.js @@ -53,6 +53,16 @@ module.exports = bookshelf.Model.extend(merge({ .orderBy('groups.name', 'asc') }, + comments: function () { + return Comment.collection().query(q => { + q.join('groups_posts', 'groups_posts.post_id', 'comments.post_id') + q.where({ + 'groups_posts.group_id': this.id, + 'comments.active': true + }) + }) + }, + creator: function () { return this.belongsTo(User, 'created_by_id') },