fixed get user comment tweets return incorrect data error

pull/354/head v0.4.0-alpha.3
Michael Li 11 months ago
parent b4f4a226f7
commit 1a41075679
No known key found for this signature in database

@ -10,7 +10,7 @@ All notable changes to paopao-ce are documented in this file.
mirgration database first(sql ddl file in `scripts/migration/**/*_create_view_post_filter.up.sql`):
```sql
CREATE VIEW p_post_by_media AS SELECT post.*FROM (SELECT DISTINCT post_id FROM p_post_content WHERE (TYPE=3 OR TYPE=4 OR TYPE=7 OR TYPE=8) AND is_del=0) media JOIN p_post post ON media.post_id=post.ID WHERE post.is_del=0;
CREATE VIEW p_post_by_comment AS SELECT P.*FROM (SELECT post_id FROM p_comment WHERE is_del=0 UNION SELECT post_id FROM p_comment_reply reply JOIN p_comment COMMENT ON reply.comment_id=COMMENT.ID WHERE reply.is_del=0 AND COMMENT.is_del=0) C JOIN p_post P ON C.post_id=P.ID WHERE P.is_del=0;
CREATE VIEW p_post_by_comment AS SELECT P.*,C.user_id comment_user_id FROM (SELECT post_id,user_id FROM p_comment WHERE is_del=0 UNION SELECT post_id,reply.user_id user_id FROM p_comment_reply reply JOIN p_comment COMMENT ON reply.comment_id=COMMENT.ID WHERE reply.is_del=0 AND COMMENT.is_del=0) C JOIN p_post P ON C.post_id=P.ID WHERE P.is_del=0;
```
- add user highlight tweet support include custom tweet set to highlight and list in user/profile page.

@ -438,7 +438,7 @@ func (s *tweetSrv) getUserTweets(db *gorm.DB, user *cs.VistUser, limit int, offs
default:
// nothing
}
db = db.Where("user_id=? AND visibility IN ? AND is_del=0", user.UserId, visibilities)
db = db.Where("visibility IN ? AND is_del=0", visibilities)
err = db.Count(&total).Error
if err != nil {
return
@ -451,12 +451,12 @@ func (s *tweetSrv) getUserTweets(db *gorm.DB, user *cs.VistUser, limit int, offs
}
func (s *tweetSrv) ListUserMediaTweets(user *cs.VistUser, limit int, offset int) ([]*ms.Post, int64, error) {
db := s.db.Table(_post_by_media_)
db := s.db.Table(_post_by_media_).Where("user_id=?", user.UserId)
return s.getUserTweets(db, user, limit, offset)
}
func (s *tweetSrv) ListUserCommentTweets(user *cs.VistUser, limit int, offset int) ([]*ms.Post, int64, error) {
db := s.db.Table(_post_by_comment_)
db := s.db.Table(_post_by_comment_).Where("comment_user_id=?", user.UserId)
return s.getUserTweets(db, user, limit, offset)
}

@ -7,17 +7,19 @@ WHERE
post.is_del = 0;
CREATE VIEW p_post_by_comment AS
SELECT P.*
SELECT P.*, C.user_id comment_user_id
FROM
(
SELECT
post_id
post_id,
user_id
FROM
p_comment
WHERE
is_del = 0 UNION
SELECT
post_id
post_id,
reply.user_id user_id
FROM
p_comment_reply reply
JOIN p_comment COMMENT ON reply.comment_id = COMMENT.ID

@ -7,17 +7,19 @@ WHERE
post.is_del = 0;
CREATE VIEW p_post_by_comment AS
SELECT P.*
SELECT P.*, C.user_id comment_user_id
FROM
(
SELECT
post_id
post_id,
user_id
FROM
p_comment
WHERE
is_del = 0 UNION
SELECT
post_id
post_id,
reply.user_id user_id
FROM
p_comment_reply reply
JOIN p_comment COMMENT ON reply.comment_id = COMMENT.ID
@ -27,4 +29,4 @@ FROM
)
C JOIN p_post P ON C.post_id = P.ID
WHERE
P.is_del = 0;
P.is_del = 0;

@ -7,17 +7,19 @@ WHERE
post.is_del = 0;
CREATE VIEW p_post_by_comment AS
SELECT P.*
SELECT P.*, C.user_id comment_user_id
FROM
(
SELECT
post_id
post_id,
user_id
FROM
p_comment
WHERE
is_del = 0 UNION
SELECT
post_id
post_id,
reply.user_id user_id
FROM
p_comment_reply reply
JOIN p_comment COMMENT ON reply.comment_id = COMMENT.ID

@ -406,17 +406,19 @@ WHERE
DROP VIEW IF EXISTS p_post_by_comment;
CREATE VIEW p_post_by_comment AS
SELECT P.*
SELECT P.*, C.user_id comment_user_id
FROM
(
SELECT
post_id
post_id,
user_id
FROM
p_comment
WHERE
is_del = 0 UNION
SELECT
post_id
post_id,
reply.user_id user_id
FROM
p_comment_reply reply
JOIN p_comment COMMENT ON reply.comment_id = COMMENT.ID

@ -337,17 +337,19 @@ WHERE
DROP VIEW IF EXISTS p_post_by_comment;
CREATE VIEW p_post_by_comment AS
SELECT P.*
SELECT P.*, C.user_id comment_user_id
FROM
(
SELECT
post_id
post_id,
user_id
FROM
p_comment
WHERE
is_del = 0 UNION
SELECT
post_id
post_id,
reply.user_id user_id
FROM
p_comment_reply reply
JOIN p_comment COMMENT ON reply.comment_id = COMMENT.ID

@ -367,17 +367,19 @@ WHERE
DROP VIEW IF EXISTS p_post_by_comment;
CREATE VIEW p_post_by_comment AS
SELECT P.*
SELECT P.*, C.user_id comment_user_id
FROM
(
SELECT
post_id
post_id,
user_id
FROM
p_comment
WHERE
is_del = 0 UNION
SELECT
post_id
post_id,
reply.user_id user_id
FROM
p_comment_reply reply
JOIN p_comment COMMENT ON reply.comment_id = COMMENT.ID

Loading…
Cancel
Save