Skip to content

feat(version): add version history tracking with GetVersionHistoryList endpoint#470

Closed
155TuT wants to merge 0 commit into
west2-online:mainfrom
155TuT:main
Closed

feat(version): add version history tracking with GetVersionHistoryList endpoint#470
155TuT wants to merge 0 commit into
west2-online:mainfrom
155TuT:main

Conversation

@155TuT
Copy link
Copy Markdown

@155TuT 155TuT commented Apr 25, 2026

  • New version_history table with GORM soft-delete for audit trail
  • GetVersionHistoryList RPC returns all version records ordered by created_at desc
  • UploadVersion now persists each uploaded version (release/beta) to version_history
  • New Thrift structs: VersionHistory, GetVersionHistoryList{Request,Response}
  • Fix incorrect error messages in UploadVersion UPYUN upload paths

自查 PR 结构

  • PR 标题符合这个格式: <type>(optional scope): <description>

  • 此 PR 标题的描述以用户为导向,足够清晰,其他人可以理解。

  • 我已经对所有 commit 提供了签名(GPG 密钥签名、SSH 密钥签名)

  • 这个 PR 属于强制变更/破坏性更改

如果是,请在 PR 标题中添加 BREAKING CHANGE 前缀,并在 PR 描述中详细说明。

这个 PR 的类型是什么?

这个 PR 做了什么 / 我们为什么需要这个 PR?

新增版本历史列表接口以便于后续后端dashboard的开发(大概)

(可选)这个 PR 解决了哪个/些 issue?

用以解决issues 446,新增版本历史列表接口,开一个pr先给大家审查,确保理解的标准和规范无误再增加其他接口

对 Reviewer 预留的一些提醒

已使用 SKILL.md 自查、通过本地编译,但未进行服务器部署测试(还不熟悉 + 没权限操作服务器)

@155TuT 155TuT requested review from a team, jiuxia211, mutezebra and ozline as code owners April 25, 2026 17:45
Copy link
Copy Markdown
Member

@renbaoshuo renbaoshuo left a comment

Choose a reason for hiding this comment

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

现在既然已经把版本信息存到了数据库里面,那么获取版本信息的时候也可以直接从数据库里面返回了,存到又拍云的 version.json 可以准备弃用掉。实现的时候记得加 Redis 缓存。

Comment thread idl/version.thrift Outdated
Comment on lines +144 to +153
struct VersionHistory{
1: required i64 id,
2: required string version,
3: required string code,
4: required string url,
5: required string feature,
6: required bool force,
7: required string type,
8: required string created_at,
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这里应该放 model 里面吧

Copy link
Copy Markdown
Author

@155TuT 155TuT Apr 26, 2026

Choose a reason for hiding this comment

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

已移到model.thrift中并删除了源文件中的 VersionHistory

Comment thread pkg/db/version/add_version_history.go Outdated
Comment on lines +36 to +47
// GetVersionHistoryList returns all version history records ordered by created_at descending.
// Returns an empty slice (not nil) when no records exist.
func (c *DBVersion) GetVersionHistoryList(ctx context.Context) ([]*model.VersionHistory, error) {
var history []*model.VersionHistory
err := c.client.WithContext(ctx).Table(constants.VersionHistoryTableName).
Order("created_at desc").
Find(&history).Error
if err != nil {
return nil, errno.Errorf(errno.InternalDatabaseErrorCode, "dal.GetVersionHistoryList error: %v", err)
}
return history, nil
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这个需要拆出来吧

Copy link
Copy Markdown
Author

@155TuT 155TuT Apr 26, 2026

Choose a reason for hiding this comment

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

已拆到 pkg/db/version/get_version_history.go,包括 GetVersionHistoryList 和GetLatestVersionByType
原文件只保留了 CreateversionHistory

@155TuT
Copy link
Copy Markdown
Author

155TuT commented Apr 26, 2026

现在既然已经把版本信息存到了数据库里面,那么获取版本信息的时候也可以直接从数据库里面返回了,存到又拍云的 version.json 可以准备弃用掉。实现的时候记得加 Redis 缓存。

GetReleaseVersion/GetBetaVersion 现在从 version_history DB 读取 10 分钟 Redis 缓存
具体改动:

  • internal/version/service/get_version.go:28-52 — Cache-Aside 模式:先查 Redis,miss 则查 DB 再回填缓存
  • pkg/cache/version/latest_version.go — GetLatestVersionCache / SetLatestVersionCache / DeleteLatestVersionCache
  • pkg/db/version/get_version_history.go:36-48 — GetLatestVersionByType 含 ErrRecordNotFound 处理
  • pkg/constants/redis.go:47,43 — LatestVersionCachePrefix + LatestVersionKeyExpire(10min)
  • internal/version/service/upload_version.go:76 — 上传后同步更新缓存

@155TuT
Copy link
Copy Markdown
Author

155TuT commented Apr 27, 2026

添加且仅添加了ssh签名(未改动上一版代码),变基到了现有的分支以在commit中不显示合并其他人的commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants