sqlx: fixed update user metric info logic not incorect error

x/sqlx
Michael Li 1 year ago
parent 1f828bd8cc
commit d8f38f256f
No known key found for this signature in database

@ -98,7 +98,7 @@ const (
_SimpleIndex_Index = `SELECT * FROM @post WHERE visibility=90 ORDER BY is_top DESC, latest_replied_on DESC LIMIT ? OFFSET ?`
_SimpleIndex_IndexCount = `SELECT count(*) FROM @post WHERE visibility=90`
_TrendsManager_CountIndexTrends = `SELECT count(*) FROM @user_relation r JOIN @user u ON r.he_uid=u.id JOIN @user_metric m ON r.he_uid=m.user_id WHERE r.user_id=? AND m.is_del=0 AND m.tweets_count>0`
_TrendsManager_GetIndexTrends = `SELECT u.username username, u.nickname nickname, u.avatar avatar FROM @user_relation r JOIN @user u ON r.he_uid=u.id JOIN @user_metric m ON r.he_uid=m.user_id WHERE r.user_id=? AND m.is_del=0 AND m.tweets_count>0 ORDER BY r.style ASC LIMIT ? OFFSET ?`
_TrendsManager_GetIndexTrends = `SELECT u.username username, u.nickname nickname, u.avatar avatar FROM @user_relation r JOIN @user u ON r.he_uid=u.id JOIN @user_metric m ON r.he_uid=m.user_id WHERE r.user_id=? AND m.is_del=0 AND m.tweets_count>0 ORDER BY r.style ASC, m.latest_trends_on DESC LIMIT ? OFFSET ?`
_Tweet_CountFollowingTweets = `SELECT count(*) FROM @post WHERE user_id=? AND is_del=0`
_Tweet_CountFollowingTweetsFollow = `SELECT count(*) FROM @post WHERE (user_id=? OR (visibility>=60 AND user_id IN(?))) AND is_del=0`
_Tweet_CountFollowingTweetsFriend = `SELECT count(*) FROM @post WHERE (user_id=? OR (visibility>=50 AND user_id IN(?))) AND is_del=0`
@ -191,7 +191,7 @@ const (
_UserMetrics_AddUserMetric = `INSERT INTO @user_metric (user_id, created_on) VALUES (?, ?)`
_UserMetrics_DeleteUserMetric = `UPDATE @user_metric SET is_del=1, deleted_on=? WHERE user_id=? AND is_del=0`
_UserMetrics_GetTweetsCount = `SELECT tweets_count FROM @user_metric WHERE user_id=? AND is_del=0`
_UserMetrics_UpdateUserMetric = `UPDATE @user_metric SET tweets_count=?, modified_on=? WHERE user_id=? AND is_del=0`
_UserMetrics_UpdateUserMetric = `UPDATE @user_metric SET tweets_count=?, latest_trends_on=?, modified_on=? WHERE user_id=? AND is_del=0`
_UserRelation_MyFollowIds = `SELECT follow_id FROM @following WHERE user_id=? AND is_del=0`
_UserRelation_MyFriendIds = `SELECT friend_id FROM @contact WHERE user_id=? AND status=2 AND is_del=0`
_Wallet_AddUserBalance = `UPDATE @user SET balance=balance+?, modified_on=? WHERE id=? AND is_del=0`

@ -91,7 +91,7 @@ func (s *userMetricSrvA) UpdateUserMetric(userId int64, action uint8) (err error
tweets_count--
}
}
_, err = s.q.UpdateUserMetric.Exec(userId, tweets_count)
_, err = s.q.UpdateUserMetric.Exec(tweets_count, now, now, userId)
return
}

@ -251,7 +251,7 @@ ON r.he_uid=m.user_id
WHERE r.user_id=?
AND m.is_del=0
AND m.tweets_count>0
ORDER BY r.style ASC
ORDER BY r.style ASC, m.latest_trends_on DESC
LIMIT ? OFFSET ?;
-- name: count_index_trends@trends_manager
@ -1373,7 +1373,9 @@ UPDATE @comment_metric SET is_del=1, deleted_on=? WHERE comment_id=? AND is_del=
-- name: update_user_metric@user_metrics
-- prepare: stmt
UPDATE @user_metric SET tweets_count=?, modified_on=? WHERE user_id=? AND is_del=0;
UPDATE @user_metric
SET tweets_count=?, latest_trends_on=?, modified_on=?
WHERE user_id=? AND is_del=0;
-- name: get_tweets_count@user_metrics
-- prepare: stmt

Loading…
Cancel
Save