From 018c829132465383813d47dfa55a31a4a1c4d879 Mon Sep 17 00:00:00 2001 From: Harshil Sharma Date: Thu, 24 Mar 2022 13:16:19 +0530 Subject: [PATCH] WIP --- server/services/store/sqlstore/templates.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/server/services/store/sqlstore/templates.go b/server/services/store/sqlstore/templates.go index f8354ce68..1bf44cd96 100644 --- a/server/services/store/sqlstore/templates.go +++ b/server/services/store/sqlstore/templates.go @@ -77,8 +77,22 @@ func (s *SQLStore) getTemplateBoards(db sq.BaseRunner, teamID, userID string) ([ query := s.getQueryBuilder(db). Select(boardFields("")...). From(s.tablePrefix+"boards as b"). - Join(s.tablePrefix+"board_members as bm on b.id = bm.board_id and b.team_id = ? and bm.user_id = ?", teamID, userID). - Where(sq.Eq{"is_template": true}) + LeftJoin(s.tablePrefix+"board_members as bm on b.id = bm.board_id and and bm.user_id = ?", userID). + Where(sq.Eq{"is_template": true}). + Where(sq.Eq{"b.team_id": teamID}). + Where(sq.Or{ + sq.And{ + sq.Eq{"bm.board_id": nil}, + sq.Eq{"b.type": model.BoardTypeOpen}, + }, + sq.And{ + sq.NotEq{"bm.board_id": nil}, + }, + }) + + ss, pp, _ := query.ToSql() + s.logger.Error(ss) + s.logger.Error(fmt.Sprintf("%v", pp)) rows, err := query.Query() if err != nil {