Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: cannot be accessed for a long time during startup #3300

Merged
merged 16 commits into from
Feb 24, 2023

Conversation

guqing
Copy link
Member

@guqing guqing commented Feb 14, 2023

What type of PR is this?

/kind improvement
/area core
/milestone 2.3.x

What this PR does / why we need it:

能通过注册 pattern 作为路由的就直接注册 pattern 以避免 Reconciler 还没结束而无法注册路由导致的访问问题。

  1. 文章、标签、分类的 permalink 规则会记录在对应 extension 的 annotations 中为 content.halo.run/permalink-pattern: some-pattern ,当系统设置中路由规则改变时会刷一遍这些资源的 content.halo.run/permalink-pattern annotation。
  2. 自定义页面的访问是通过 SinglePageRoute 控制,它会在 single page 添加、更新、删除时维护 quickRouteMap 的集合,在路由到它时直接通过 request path 查找 map key,找到则直接返回 HandleFunction。
  3. 除了自定义页面外其他都是通过 ThemeCompositeRouterFunction 作为路由管理器,系统启动时文章等的 RouterFunction 会被生成并缓存到 cachedRouters 的一个 List 集合中,当路由规则改变会清理它重新赋值。

Which issue(s) this PR fixes:

Fixes #3254

Special notes for your reviewer:

how to test it?

  1. 测试首页、文章、标签、分类、归档页、自定义页面和作者页等的访问。
  2. 测试添加、删除资源和修改系统路由规则后上述资源的访问。
  3. 测试分页路径如 /tags/slug/page/1 的访问。

/cc @halo-dev/sig-halo

Does this PR introduce a user-facing change?

 优化启动时页面长时间无法访问的问题

@f2c-ci-robot f2c-ci-robot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/improvement Categorizes issue or PR as related to a improvement. labels Feb 14, 2023
@f2c-ci-robot f2c-ci-robot bot added this to the 2.3.x milestone Feb 14, 2023
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label Feb 14, 2023
@guqing guqing changed the title Refactor/3254 perf: cannot be accessed for a long time during startup Feb 14, 2023
@ruibaby
Copy link
Member

ruibaby commented Feb 14, 2023

测试发现,页面的路由修改别名之后,以前的路径也可以访问,比如:

  • 以前的链接是:/test/test
  • 修改为:/test/test/test

修改之后两个链接都可以访问。

@guqing
Copy link
Member Author

guqing commented Feb 14, 2023

已修复

@f2c-ci-robot f2c-ci-robot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 15, 2023
@ruibaby
Copy link
Member

ruibaby commented Feb 20, 2023

@guqing 需要解决一下冲突。

# Conflicts:
#	src/main/java/run/halo/app/core/extension/reconciler/TagReconciler.java
#	src/test/java/run/halo/app/core/extension/reconciler/TagReconcilerTest.java
@f2c-ci-robot f2c-ci-robot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 21, 2023
@guqing
Copy link
Member Author

guqing commented Feb 21, 2023

@guqing 需要解决一下冲突。

Done

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.

经过手动测试,暂时发现一个问题:

  1. 文章路由设置为 /?p={name}
  2. 访问文章列表,得到的文章链接是正确的
  3. 但都指向第一篇文章

@guqing
Copy link
Member Author

guqing commented Feb 22, 2023

经过手动测试,暂时发现一个问题:

  1. 文章路由设置为 /?p={name}
  2. 访问文章列表,得到的文章链接是正确的
  3. 但都指向第一篇文章

已修复

Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

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

/approve

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 22, 2023
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.

目前,我在测试当前 PR 的时候,发现一个小问题(可能和当前 PR 无关):修改“分类和标签的路由前缀”后,主题端对应的分类和标签链接渲染并没有正确变更,导致无法正常访问。

@guqing
Copy link
Member Author

guqing commented Feb 24, 2023

目前,我在测试当前 PR 的时候,发现一个小问题(可能和当前 PR 无关):修改“分类和标签的路由前缀”后,主题端对应的分类和标签链接渲染并没有正确变更,导致无法正常访问。

这是由于主题端渲染的链接来自 status.permalink 而 status.permalink 路由规则改了后需要 reconciler 一个个去运行后才能更新为正确的数据

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.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2023
@f2c-ci-robot f2c-ci-robot bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2023
@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Merging #3300 (dc360f9) into main (ce80ed4) will decrease coverage by 1.02%.
The diff coverage is 50.68%.

@@             Coverage Diff              @@
##               main    #3300      +/-   ##
============================================
- Coverage     60.99%   59.98%   -1.02%     
+ Complexity     2490     2376     -114     
============================================
  Files           399      388      -11     
  Lines         12664    12268     -396     
  Branches       1043      985      -58     
============================================
- Hits           7725     7359     -366     
- Misses         4431     4437       +6     
+ Partials        508      472      -36     
Impacted Files Coverage Δ
...n/halo/app/content/permalinks/PermalinkPolicy.java 100.00% <ø> (ø)
.../run/halo/app/core/extension/content/Constant.java 0.00% <ø> (ø)
...java/run/halo/app/core/extension/content/Post.java 83.72% <ø> (ø)
...ore/extension/reconciler/SinglePageReconciler.java 50.71% <ø> (-2.39%) ⬇️
.../app/core/extension/reconciler/UserReconciler.java 46.80% <ø> (-2.25%) ⬇️
...pp/infra/SystemConfigurableEnvironmentFetcher.java 70.00% <0.00%> (-1.19%) ⬇️
...pp/theme/dialect/ContentTemplateHeadProcessor.java 83.87% <ø> (ø)
...app/theme/dialect/TemplateGlobalHeadProcessor.java 94.44% <ø> (ø)
...un/halo/app/theme/finders/impl/PostFinderImpl.java 69.14% <ø> (ø)
...un/halo/app/theme/router/factories/ModelConst.java 100.00% <ø> (ø)
... and 43 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2023
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Feb 24, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang, ruibaby

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@JohnNiang JohnNiang merged commit 9fff768 into halo-dev:main Feb 24, 2023
@ruibaby ruibaby modified the milestones: 2.3.x, 2.3.0 Feb 24, 2023
@guqing guqing deleted the refactor/3254 branch February 24, 2023 10:59
f2c-ci-robot bot pushed a commit that referenced this pull request Feb 28, 2023
#### What type of PR is this?
/kind bug
/area core
/milestone 2.3.x
#### What this PR does / why we need it:
修复文章列表分页配置取值错误的问题
此问题为 #3300 PR 引入,由于改动较大遗漏了这点没测试到。

how to test it?
修改文章设置中的大小,查看主题端分页是否符合预期:
包括首页,归档页,标签文章页,分类文章页。
<img width="575" alt="image" src="https://user-images.githubusercontent.com/38999863/221574440-eeec9c27-57ab-46d1-823f-7cc076fb2b54.png">

#### Which issue(s) this PR fixes:
Fixes #3411

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
None
```
f2c-ci-robot bot pushed a commit that referenced this pull request Mar 8, 2023
#### What type of PR is this?
/kind bug
/area core
/milestone 2.3.x

#### What this PR does / why we need it:
修复文章和自定义页面缺失 name 模型属性导致的访问量无法计数问题
此为 2.3.0 引入的问题 see #3300

how to test it?
1. 切换文章的路由为不带 name 的规则
2. 访问文章看 `/apis/api.halo.run/v1alpha1/trackers/counter` API 是否有如下参数,且 name 值正确
```json
{
    "group": "content.halo.run",
    "plural": "posts",
    "name": "335",
    "hostname": "localhost",
    "screen": "1920x1080",
    "language": "zh-CN",
    "url": "/?p=halo-150-released",
    "referrer": "http://localhost:8090/?p=how-to-development-a-halo-plugin"
}
```
3. 观察文章访问量是否有增加
4. 重复上述 2、3 步骤检查自定义页面的访问量功能是否正确

#### Which issue(s) this PR fixes:

Fixes #3448

#### Does this PR introduce a user-facing change?
```release-note
修复文章和自定义页面缺失属性导致的访问量无法计数问题
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

优化系统启动时主题端的链接访问
3 participants