@@ -78,10 +78,12 @@ func (appr *appreciationsStore) GetAppreciationById(ctx context.Context, tx repo
7878 return repository.AppreciationResponse {}, apperrors .InternalServer
7979 }
8080
81+
8182 // Build the SQL query
8283 query , args , err := repository .Sq .Select (
8384 "a.id" ,
8485 "cv.name AS core_value_name" ,
86+ "cv.description AS core_value_description" ,
8587 "a.description" ,
8688 "a.is_valid" ,
8789 "a.total_reward_points" ,
@@ -91,6 +93,7 @@ func (appr *appreciationsStore) GetAppreciationById(ctx context.Context, tx repo
9193 "u_sender.last_name AS sender_last_name" ,
9294 "u_sender.profile_image_url AS sender_image_url" ,
9395 "u_sender.designation AS sender_designation" ,
96+ "g_sender.name AS sender_grade_name" ,
9497 "u_receiver.id AS receiver_id" ,
9598 "u_receiver.first_name AS receiver_first_name" ,
9699 "u_receiver.last_name AS receiver_last_name" ,
@@ -107,14 +110,15 @@ func (appr *appreciationsStore) GetAppreciationById(ctx context.Context, tx repo
107110 ), 0) AS given_reward_point` , userID ),
108111 ).From (appr .AppreciationsTable + " a" ).
109112 LeftJoin (appr .UsersTable + " u_sender ON a.sender = u_sender.id" ).
113+ LeftJoin ("grades g_sender ON u_sender.grade_id = g_sender.id" ).
110114 LeftJoin (appr .UsersTable + " u_receiver ON a.receiver = u_receiver.id" ).
111115 LeftJoin (appr .CoreValuesTable + " cv ON a.core_value_id = cv.id" ).
112116 LeftJoin (appr .RewardsTable + " r ON a.id = r.appreciation_id" ).
113117 Where (squirrel.And {
114118 squirrel.Eq {"a.id" : apprId },
115119 squirrel.Eq {"a.is_valid" : true },
116120 }).
117- GroupBy ("a.id" , "cv.name" , "u_sender.id" , "u_receiver.id" ).
121+ GroupBy ("a.id" , "cv.name" , "cv.description" , " u_sender.id" , "g_sender.name " , "u_receiver.id" ).
118122 ToSql ()
119123
120124 if err != nil {
@@ -213,12 +217,13 @@ func (appr *appreciationsStore) ListAppreciations(ctx context.Context, tx reposi
213217 "u_sender.profile_image_url AS sender_image_url" ,
214218 "u_sender.designation AS sender_designation" ,
215219 "u_sender.employee_id AS sender_employee_id" ,
220+ "g_sender.name AS sender_grade_name" ,
216221 "u_receiver.id AS receiver_id" ,
217222 "u_receiver.first_name AS receiver_first_name" ,
218223 "u_receiver.last_name AS receiver_last_name" ,
219224 "u_receiver.profile_image_url AS receiver_image_url" ,
220225 "u_receiver.designation AS receiver_designation" ,
221- "u_receiver.employee_id AS receiver_employee_id" ,
226+ "u_receiver.employee_id AS receiver_employee_id" ,
222227 "a.created_at" ,
223228 "a.updated_at" ,
224229 "COUNT(r.id) AS total_rewards" ,
@@ -229,8 +234,9 @@ func (appr *appreciationsStore) ListAppreciations(ctx context.Context, tx reposi
229234 WHERE r2.appreciation_id = a.id AND r2.sender = %d
230235 ), 0) AS given_reward_point` , userID ),
231236 ).
237+ LeftJoin ("grades g_sender ON u_sender.grade_id = g_sender.id" ).
232238 LeftJoin ("rewards r ON a.id = r.appreciation_id" ).
233- GroupBy ("a.id" , "cv.name" , "cv.description" , "u_sender.id" , "u_receiver.id" )
239+ GroupBy ("a.id" , "cv.name" , "cv.description" , "u_sender.id" , "g_sender.name" , " u_receiver.id" )
234240
235241 if filter .SortOrder != "" {
236242 queryBuilder = queryBuilder .OrderBy (fmt .Sprintf ("a.created_at %s" , filter .SortOrder ))
0 commit comments