Skip to content

Conversation

@guqing
Copy link
Member

@guqing guqing commented Jan 8, 2022

What this PR does?

  • 将文章内容从文章表中拆分出去
  • 增加文章内容版本表用来存储内容版本增量记录
  • 修改原有文章编辑逻辑后台编辑时不影响前台预览,只有发布后才能在前台展示最新内容

Why we need it?

#1587

How to test it?

  1. 针对Post和Sheet做保存和发布操作,期望内容不会出现丢失,保存草稿时期望不会在前台显示只有发布后才会同步到前台
  2. 做发布操作后观察数据库中content_patch_logs表中的version,期望值随发布次数递增
  3. 后台点击预览时期望查看到最新内容
  4. 后台文章列表和文章详情接口期望返回inProgress字段
  5. 先使用1.4.17版本启动实例,登陆到后台创建各种状态的文章和页面,然后切换到该PR再次启动会执行迁移脚本,观察数据库,期望看到contents和contents_patch_logs表并且表中存在数据,再次登陆后台对文章进行保存和发布,期望文章内容和未使用该PR启动时一致且操作不会报错且前台文章列表和内容详情显示正常。
  6. 登陆后台分别创建页面及文章,观察未发布过的草稿文章在content_patch_logs中的记录sourceId为0,发布过的文章最新的content_patch_logs记录为该文章上一条content_patch_logs记录的id

Remark

对ContentPatchLog添加表索引测试情景如下:
1.Finds patchlogs by post id and status order by version

explain
select *
from content_patch_logs
where post_id = 3
  and status = 1 order by version desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE content_patch_logs ref|filter idx_post_id,idx_status idx_status|idx_post_id 5|5 const 1 (63%) Using where; Using filesort; Using rowid filter

2.Finds patchlogs by post id and status and version order by version

explain
select *
from content_patch_logs
where post_id = 3
  and status = 0 and version=3 order by version desc ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE content_patch_logs ref|filter idx_post_id,idx_status,idx_version idx_version|idx_post_id 4|5 const 1 (63%) Using where; Using rowid filter

3.Finds patchlogs by post id

explain
select *
from content_patch_logs
where post_id = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE content_patch_logs ref idx_post_id idx_post_id 5 const 1

@guqing guqing marked this pull request as draft January 8, 2022 10:22
@JohnNiang JohnNiang added this to the 1.5.x milestone Jan 9, 2022
@guqing guqing self-assigned this Feb 16, 2022
@guqing guqing added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 16, 2022
@guqing guqing marked this pull request as ready for review February 16, 2022 12:31
@guqing guqing changed the title [WIP] Split post content to new table and support content version control Split post content to new table and support content version control Feb 16, 2022
@guqing guqing requested review from JohnNiang and ruibaby February 16, 2022 12:32
@ruibaby
Copy link
Member

ruibaby commented Feb 17, 2022

cc @JohnNiang

@ruibaby
Copy link
Member

ruibaby commented Feb 17, 2022

image

RSS 没有输出内容。

@guqing
Copy link
Member Author

guqing commented Feb 17, 2022

image

RSS 没有输出内容。

ok got it

@guqing guqing requested a review from ruibaby February 18, 2022 03:22
@guqing guqing changed the title Split post content to new table and support content version control WIP: Split post content to new table and support content version control Feb 19, 2022
@guqing
Copy link
Member Author

guqing commented Feb 19, 2022

测试索引时发现 contents 表中的type字段没有用到,于是发现不需要这个字段,因为contents表的主键id设计为使用posts表的主键id,所以不需要像 post 和 sheet 共用表那样写,直接用一个 Content entity + ContentRespoitory + ContentService即可存储和使用post和sheet的内容,于是 commit#351d5c 用来优化此项发现,简化了300多行代码

@guqing guqing changed the title WIP: Split post content to new table and support content version control Split post content to new table and support content version control Feb 19, 2022
@guqing
Copy link
Member Author

guqing commented Feb 19, 2022

@ruibaby @JohnNiang ready for review

Copy link
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缺乏一些必要的单元测试,尤其是新增的 Content 部分。

@guqing guqing requested a review from JohnNiang February 19, 2022 15:27
@JohnNiang
Copy link
Member

@guqing 文章的描述似乎丢失了,请看图片:
image

@guqing
Copy link
Member Author

guqing commented Feb 20, 2022

@guqing 文章的描述似乎丢失了,请看图片:
image

@JohnNiang 如何操作的呢

@JohnNiang
Copy link
Member

JohnNiang commented Feb 20, 2022

Hi @guqing ,左侧是基于 master 分支初始化博客,右侧则是基于当前 PR 初始化博客的结果。

@guqing guqing requested a review from JohnNiang February 20, 2022 09:35
@JohnNiang JohnNiang merged commit 923eb17 into halo-dev:master Feb 20, 2022
@guqing guqing deleted the feature/1587 branch February 20, 2022 12:37
winar-jin pushed a commit to winar-jin/halo that referenced this pull request Mar 24, 2022
* feat: split post content to new table and support content version control

* feat: Improve post version management

* feat: Add post content and version record deletion

* feat: Add isInProcess attribute for post list and detail api

* feat: Add migrate sql script

* fix: Add a sql of allow origin_content to null in posts table

* feat: Assign a value to the source of the post content version record
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

将文章内容从文章表拆分出去或查询文章列表时不附带查询文章内容

3 participants