fixed sqlite3 sql migration script error and optimize following tweets order to DESC

pull/388/head
Michael Li 1 year ago
parent 53a4aef5f4
commit 7c6cb0a463
No known key found for this signature in database

@ -489,7 +489,7 @@ func (s *tweetSrv) ListFollowingTweets(userId int64, limit, offset int) (res []*
if offset >= 0 && limit > 0 { if offset >= 0 && limit > 0 {
db = db.Offset(offset).Limit(limit) db = db.Offset(offset).Limit(limit)
} }
if err = db.Find(&res).Error; err != nil { if err = db.Order("is_top DESC, latest_replied_on DESC").Find(&res).Error; err != nil {
return return
} }
return return

@ -2,7 +2,7 @@ DROP TABLE IF EXISTS "p_post_metric";
-- 原来的可见性: 0公开 1私密 2好友可见 3关注可见 -- 原来的可见性: 0公开 1私密 2好友可见 3关注可见
-- 现在的可见性: 0私密 10充电可见 20订阅可见 30保留 40保留 50好友可见 60关注可见 70保留 80保留 90公开 -- 现在的可见性: 0私密 10充电可见 20订阅可见 30保留 40保留 50好友可见 60关注可见 70保留 80保留 90公开
UPDATE p_post a UPDATE p_post AS a
SET visibility = ( SET visibility = (
SELECT SELECT
CASE visibility CASE visibility
@ -13,7 +13,7 @@ SET visibility = (
ELSE 0 ELSE 0
END END
FROM FROM
p_post b p_post AS b
WHERE WHERE
a.ID = b.ID a.ID = b.ID
); );

@ -2,13 +2,13 @@ CREATE TABLE "p_post_metric" (
"id" integer NOT NULL, "id" integer NOT NULL,
"post_id" integer NOT NULL, "post_id" integer NOT NULL,
"rank_score" integer NOT NULL, "rank_score" integer NOT NULL,
"incentive_score" integer NOT NULL, "incentive_score" integer NOT NULL DEFAULT 0,
"decay_factor" integer NOT NULL, "decay_factor" integer NOT NULL DEFAULT 0,
"motivation_factor" integer NOT NULL, "motivation_factor" integer NOT NULL DEFAULT 0,
"is_del" integer NOT NULL, "is_del" integer NOT NULL DEFAULT 0,
"created_on" integer NOT NULL, "created_on" integer NOT NULL DEFAULT 0,
"modified_on" integer NOT NULL, "modified_on" integer NOT NULL DEFAULT 0,
"deleted_on" integer NOT NULL, "deleted_on" integer NOT NULL DEFAULT 0,
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
@ -27,7 +27,7 @@ WHERE is_del=0;
-- 原来的可见性: 0公开 1私密 2好友可见 3关注可见 -- 原来的可见性: 0公开 1私密 2好友可见 3关注可见
-- 现在的可见性: 0私密 10充电可见 20订阅可见 30保留 40保留 50好友可见 60关注可见 70保留 80保留 90公开 -- 现在的可见性: 0私密 10充电可见 20订阅可见 30保留 40保留 50好友可见 60关注可见 70保留 80保留 90公开
UPDATE p_post a UPDATE p_post AS a
SET visibility = ( SET visibility = (
SELECT SELECT
CASE visibility CASE visibility
@ -38,7 +38,7 @@ SET visibility = (
ELSE 0 ELSE 0
END END
FROM FROM
p_post b p_post AS b
WHERE WHERE
a.ID = b.ID a.ID = b.ID
); );

@ -221,13 +221,13 @@ CREATE TABLE "p_post_metric" (
"id" integer NOT NULL, "id" integer NOT NULL,
"post_id" integer NOT NULL, "post_id" integer NOT NULL,
"rank_score" integer NOT NULL, "rank_score" integer NOT NULL,
"incentive_score" integer NOT NULL, "incentive_score" integer NOT NULL DEFAULT 0,
"decay_factor" integer NOT NULL, "decay_factor" integer NOT NULL DEFAULT 0,
"motivation_factor" integer NOT NULL, "motivation_factor" integer NOT NULL DEFAULT 0,
"is_del" integer NOT NULL, "is_del" integer NOT NULL DEFAULT 0,
"created_on" integer NOT NULL, "created_on" integer NOT NULL DEFAULT 0,
"modified_on" integer NOT NULL, "modified_on" integer NOT NULL DEFAULT 0,
"deleted_on" integer NOT NULL, "deleted_on" integer NOT NULL DEFAULT 0,
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );

Loading…
Cancel
Save