// UpdateUserLikedCount updates user liked count. func UpdateUserLikedCount(c *gin.Context) (int, error) { log.Debug("UpdateUserLikedCount performed") currentUserSrc, err := userService.CurrentUser(c) var currentUser model.User if err != nil { return http.StatusUnauthorized, err } db.ORM.First(¤tUser, currentUserSrc.Id) currentUser.LikedCount = db.ORM.Model(currentUser).Association("Liked").Count() log.Debugf("LikedCount : %d", currentUser.LikedCount) if db.ORM.Save(currentUser).Error != nil { return http.StatusInternalServerError, errors.New("User liked count is not updated.") } return http.StatusOK, nil }