Skip to content

fix(appapi): map rankings zone name to number and fix period parameter - #13

Merged
FlanChanXwO merged 2 commits into
FlanChanXwO:mainfrom
kanoshiou:fix/rankings-type-filter
Aug 9, 2026
Merged

FlanChanXwO merged 2 commits into
FlanChanXwO:mainfrom
kanoshiou:fix/rankings-type-filter

Conversation

@kanoshiou

@kanoshiou kanoshiou commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary / 概述

This PR fixes the movie and playback rankings endpoints. Specifically, it maps textual zone names (e.g., censored, uncensored, western, fc2) to their corresponding API numeric identifiers before sending requests to the JavDB App API. It also updates the rankings commands to use RankingPeriod (renamed from ActorPeriod) for proper query parameter mapping.

Scope and compatibility / 范围与兼容性

  • CLI Commands / Flags:
    • javdb rankings movies --type and javdb rankings playback --filter-by now correctly accept and resolve textual zones (including the newly added fc2 option).
  • Public Go SDK:
    • Renamed and re-exported ActorPeriod to RankingPeriod in the public javdb facade.

Verification / 验证

Successfully ran unit tests verifying query mapping behavior for both movies and playback endpoints:

go test ./...
ok  	github.com/FlanChanXwO/javdb-cli/internal/cli	1.528s
ok  	github.com/FlanChanXwO/javdb-cli/internal/javdb/appapi	1.098s
ok  	github.com/FlanChanXwO/javdb-cli/sdk	(cached)

Release note declaration / Release note 声明

Checklist / 检查清单

  • The change is focused and linked to an issue when appropriate.
  • I added or updated focused tests for changed behavior.
  • I ran the relevant tests and recorded the results above.
  • I updated the required CLI reference, SDK, README, maintainer, and operator-skill documentation.
  • I completed the required release-note declaration above.
  • I documented every new timeout, retry, pagination or result limit, truncation, fallback, or downgrade and its evidence.
  • I did not add passwords, JWTs, ~/.javdb-cli/auth.json contents, proxy credentials, private URLs, local state, or private API responses.
  • I updated migration guidance for every breaking change.

Summary by Sourcery

修复电影、演员和播放的排行榜 API 查询映射,并更新 CLI 和 SDK 的命名以使用 RankingPeriod。

新功能:

  • 允许排行榜中的电影和播放 CLI 命令在现有区域选项基础上额外接受 fc2 区域选项。

错误修复:

  • 为电影和播放排行榜请求,将文本形式的区域名称映射为数值类型/filter_by 值。
  • 确保所有排行榜端点中的排行榜周期值能够从 day/week/month 转换为 daily/weekly/monthly。

改进:

  • 将 ActorPeriod 辅助工具重命名为 RankingPeriod,并在 SDK 中重新导出,以在所有排行榜端点中保持术语一致。

测试:

  • 添加集成风格测试,通过测试 HTTP 服务器验证电影和播放排行榜的查询参数映射。
  • 更新周期映射的单元测试,以覆盖重命名后的 RankingPeriod 辅助工具。
Original summary in English

Summary by Sourcery

Fix rankings API query mapping for movies, actors, and playback, and update CLI and SDK naming to use RankingPeriod.

New Features:

  • Allow rankings movies and playback CLI commands to accept the fc2 zone option alongside existing zones.

Bug Fixes:

  • Map textual zone names to numeric type/filter_by values for movie and playback rankings requests.
  • Ensure rankings period values are translated from day/week/month to daily/weekly/monthly for all rankings endpoints.

Enhancements:

  • Rename the ActorPeriod helper to RankingPeriod and re-export it in the SDK for consistent terminology across rankings endpoints.

Tests:

  • Add integration-style tests to verify query parameter mapping for movie and playback rankings against a test HTTP server.
  • Update period-mapping unit test to cover the renamed RankingPeriod helper.

Summary by CodeRabbit

  • 新功能

    • 排行榜类型筛选新增 fc2 选项。
    • 电影、演员和播放榜单支持统一的日、周、月周期筛选。
    • 榜单区域与筛选条件可更准确地传递并应用。
  • 改进

    • 更新排行榜周期辅助接口名称,提升电影、演员和播放榜单的一致性。

@sourcery-ai

sourcery-ai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

将文本排名区域映射到数值 API 标识符,通过重命名后的辅助函数集中管理排名周期映射,将 CLI 标志和 SDK 接入新的映射逻辑,并添加针对电影和回放排名的查询参数映射的测试,这些测试会对接一个用于验证的 HTTP 测试服务器。

带区域和周期映射的排名请求时序图

sequenceDiagram
  actor User
  participant CLI as rankings_cmd
  participant SDK as sdk.Client
  participant AppAPI as appapi.Client
  participant JavDB as JavDB_App_API

  User->>CLI: run javdb rankings movies --type fc2 --period day
  CLI->>SDK: RankingsMovies(ctx,"fc2","day")
  SDK->>AppAPI: RankingsMovies("fc2","day")
  AppAPI->>AppAPI: RankingPeriod("day")
  AppAPI->>AppAPI: Zones["fc2"]
  AppAPI->>JavDB: GetJSON("/api/v1/rankings",{"type":strconv.Itoa(Zones["fc2"]),"period":RankingPeriod("day")})

  User->>CLI: run javdb rankings playback --filter-by western --period month
  CLI->>SDK: RankingsPlayback(ctx,"western","month")
  SDK->>AppAPI: RankingsPlayback("western","month")
  AppAPI->>AppAPI: RankingPeriod("month")
  AppAPI->>AppAPI: Zones["western"]
  AppAPI->>JavDB: GetJSON("/api/v1/rankings/playback",{"filter_by":strconv.Itoa(Zones["western"]),"period":RankingPeriod("month")})
Loading

File-Level Changes

Change Details Files
将排名周期映射逻辑集中起来并重命名,同时更新 SDK 和 CLI 以使用该逻辑。
  • 在应用 API 中将 ActorPeriod 辅助函数重命名为 RankingPeriod,并保持其 day/week/month → daily/weekly/monthly 的映射语义不变。
  • 更新 RankingsActors 应用 API 实现,使其在处理 type/period 参数时使用 RankingPeriod。
  • 修改对外公开的 SDK 外观层,使其重新导出 RankingPeriod 而不是 ActorPeriod,并相应调整 RankingsActors 的注释。
  • 更新 CLI 的 rankings actors 命令,在调用 RankingsActors 时改为调用 javdb.RankingPeriod。
internal/javdb/appapi/rankings.go
sdk/rankings.go
internal/cli/rankings_cmd.go
为电影和回放排名请求将文本排名区域映射为数值标识符。
  • 在 RankingsMovies 和 RankingsPlayback 中引入区域到数字的映射查找,使用现有的 Zones 映射表和 strconv.Itoa。
  • 确保 RankingsMovies 在向 /api/v1/rankings 发送请求时,将已映射的数值 type 和 RankingPeriod(period) 作为查询参数。
  • 确保 RankingsPlayback 在向 /api/v1/rankings/playback 发送请求时,将已映射的数值 filter_by 和 RankingPeriod(period) 作为查询参数。
  • 扩展 CLI 中 rankings movies 的 --type 和 rankings playback 的 --filter-by 标志说明,宣传新的 fc2 区域选项。
internal/javdb/appapi/rankings.go
internal/cli/rankings_cmd.go
添加 HTTP 级别测试,用于验证电影和回放的排名查询参数映射。
  • 扩展 rankings_test.go 的导入,加入 net/http 和 net/http/httptest。
  • 添加 TestRankingPeriod 以替换 TestActorPeriod,用于验证辅助函数的映射行为。
  • 添加 TestRankingsMoviesQueryMapping,使用 httptest.Server 断言多种文本和数值 type 输入会产生预期的 type 和 period 查询参数。
  • 添加 TestRankingsPlaybackQueryMapping,使用 httptest.Server 断言多种文本和数值 filter_by 输入会产生预期的 filter_by 和 period 查询参数。
internal/javdb/appapi/rankings_test.go

Tips and commands

Interacting with Sourcery

  • 触发新的审核: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审核评论。
  • 从审核评论生成 GitHub issue: 回复审核评论,要求 Sourcery 基于该评论创建 issue。你也可以回复审核评论并写上 @sourcery-ai issue 来基于该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文任意位置写上 @sourcery-ai summary,即可在指定位置生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成评审者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时(重新)生成评审者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 撤销所有 Sourcery 审核: 在拉取请求中评论 @sourcery-ai dismiss,即可撤销所有现有的 Sourcery 审核。尤其适用于你希望从一次全新的审核开始的场景 —— 记得随后评论 @sourcery-ai review 来触发新的审核!

Customizing Your Experience

访问你的 dashboard 来:

  • 启用或禁用诸如 Sourcery 自动生成的拉取请求摘要、评审者指南等审核功能。
  • 更改审核语言。
  • 添加、移除或编辑自定义审核说明。
  • 调整其他审核设置。

Getting Help

Original review guide in English

Reviewer's Guide

Maps textual rankings zones to numeric API identifiers, centralizes rankings period mapping via a renamed helper, wires CLI flags and SDK to use the new mappings, and adds tests that verify query parameter mapping for movie and playback rankings against a test HTTP server.

Sequence diagram for rankings requests with zone and period mapping

sequenceDiagram
  actor User
  participant CLI as rankings_cmd
  participant SDK as sdk.Client
  participant AppAPI as appapi.Client
  participant JavDB as JavDB_App_API

  User->>CLI: run javdb rankings movies --type fc2 --period day
  CLI->>SDK: RankingsMovies(ctx,"fc2","day")
  SDK->>AppAPI: RankingsMovies("fc2","day")
  AppAPI->>AppAPI: RankingPeriod("day")
  AppAPI->>AppAPI: Zones["fc2"]
  AppAPI->>JavDB: GetJSON("/api/v1/rankings",{"type":strconv.Itoa(Zones["fc2"]),"period":RankingPeriod("day")})

  User->>CLI: run javdb rankings playback --filter-by western --period month
  CLI->>SDK: RankingsPlayback(ctx,"western","month")
  SDK->>AppAPI: RankingsPlayback("western","month")
  AppAPI->>AppAPI: RankingPeriod("month")
  AppAPI->>AppAPI: Zones["western"]
  AppAPI->>JavDB: GetJSON("/api/v1/rankings/playback",{"filter_by":strconv.Itoa(Zones["western"]),"period":RankingPeriod("month")})
Loading

File-Level Changes

Change Details Files
Centralize and rename rankings period mapping logic and update SDK and CLI to use it.
  • Rename ActorPeriod helper in the app API to RankingPeriod and keep its day/week/month → daily/weekly/monthly mapping semantics.
  • Update RankingsActors app API implementation to use RankingPeriod for its type/period parameter.
  • Change the public SDK facade to re-export RankingPeriod instead of ActorPeriod and adjust RankingsActors comments accordingly.
  • Update CLI rankings actors command to call javdb.RankingPeriod when invoking RankingsActors.
internal/javdb/appapi/rankings.go
sdk/rankings.go
internal/cli/rankings_cmd.go
Map textual rankings zones to numeric identifiers for movies and playback rankings requests.
  • Introduce zone-to-number mapping lookups in RankingsMovies and RankingsPlayback using the existing Zones map and strconv.Itoa.
  • Ensure RankingsMovies sends mapped numeric type and RankingPeriod(period) as query parameters to /api/v1/rankings.
  • Ensure RankingsPlayback sends mapped numeric filter_by and RankingPeriod(period) as query parameters to /api/v1/rankings/playback.
  • Extend CLI flags for rankings movies --type and rankings playback --filter-by to advertise the new fc2 zone option.
internal/javdb/appapi/rankings.go
internal/cli/rankings_cmd.go
Add HTTP-level tests to validate rankings query parameter mapping for movies and playback.
  • Expand rankings_test.go imports to include net/http and net/http/httptest.
  • Add TestRankingPeriod to replace TestActorPeriod and verify the helper’s mapping behavior.
  • Add TestRankingsMoviesQueryMapping using an httptest.Server to assert that various textual and numeric type inputs produce the expected type and period query parameters.
  • Add TestRankingsPlaybackQueryMapping using an httptest.Server to assert that various textual and numeric filter_by inputs produce the expected filter_by and period query parameters.
internal/javdb/appapi/rankings_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kanoshiou, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7dffc7b3-dc3b-4b33-9908-c4e08f195a15

📥 Commits

Reviewing files that changed from the base of the PR and between 42ffd94 and 3da5d6f.

📒 Files selected for processing (4)
  • internal/cli/rankings_cmd.go
  • internal/javdb/appapi/rankings.go
  • internal/javdb/appapi/rankings_test.go
  • sdk/rankings.go
📝 Walkthrough

Walkthrough

本次变更统一榜单周期辅助函数名称,转换电影和播放榜单的区域筛选参数,并在 CLI 帮助中加入 fc2。新增本地 HTTP 测试,验证周期、类型、筛选条件和错误处理。

Changes

榜单参数统一

Layer / File(s) Summary
周期辅助函数与公开导出
internal/javdb/appapi/rankings.go, sdk/rankings.go, internal/cli/rankings_cmd.go
将 ActorPeriod 重命名为 RankingPeriod,并更新 SDK 导出和演员榜单调用。
榜单查询参数映射
internal/javdb/appapi/rankings.go, internal/cli/rankings_cmd.go
电影、演员和播放榜单转换周期参数及区域筛选参数。CLI 帮助文本新增 fc2。
查询参数映射测试
internal/javdb/appapi/rankings_test.go
使用本地 HTTP 服务验证周期、类型、筛选条件、查询值和请求错误。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • FlanChanXwO/javdb-cli#11:同样修改 sdk/rankings.go 的榜单周期辅助函数,但该变更引入了 ActorPeriod。

Suggested reviewers: flanchanxwo

Poem

兔子敲键盘,榜单周期排成行
RankingPeriod 把日期换新装
fc2 选项跃入帮助栏
区域参数化成数字跑向 API
HTTP 小测试守住查询门
胡萝卜庆祝映射无误 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了排行榜区域名称映射和周期参数修复,符合变更的主要目标。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - 我发现了两个问题,并给出了一些高层次的反馈:

  • 目前 CLI 会调用 javdb.RankingPeriod,而 app API client 在内部也会应用 RankingPeriod,这会让 period 的映射变得重复;建议在 CLI 层传递原始的 period 值,并把映射逻辑集中到同一层来处理。
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- 目前 CLI 会调用 `javdb.RankingPeriod`,而 app API client 在内部也会应用 `RankingPeriod`,这会让 period 的映射变得重复;建议在 CLI 层传递原始的 period 值,并把映射逻辑集中到同一层来处理。

## Individual Comments

### Comment 1
<location path="internal/javdb/appapi/rankings.go" line_range="64-65" />
<code_context>

 // RankingsMovies GET /api/v1/rankings
 func (c *Client) RankingsMovies(type_, period string) (SearchResult, error) {
+	t := type_
+	if z, ok := Zones[type_]; ok {
+		t = strconv.Itoa(z)
+	}
</code_context>
<issue_to_address>
**suggestion:** 针对 `type_` 的 Zone 到 int 映射存在重复实现,可以集中处理。

这里的 `type_` → `Zones` → `strconv.Itoa` 逻辑与 `RankingsPlayback` 中对 `filterBy` 的处理一致。请提取一个共享的辅助函数(例如 `normalizeZone(string) string`),并在两个地方都使用它,以消除重复代码,并确保当映射发生变化时,区域归一化逻辑保持一致。

建议实现:

```golang
func normalizeZone(zone string) string {
	if z, ok := Zones[zone]; ok {
		return strconv.Itoa(z)
	}
	return zone
}

// RankingsMovies GET /api/v1/rankings
func (c *Client) RankingsMovies(type_, period string) (SearchResult, error) {
	t := normalizeZone(type_)

```

```golang
	var data map[string]json.RawMessage
	if err := c.GetJSON("/api/v1/rankings", map[string]string{
		"type": t, "period": RankingPeriod(period),
	}, &data); err != nil {
		return nil, err
	}
func (c *Client) RankingsActors(period string) (SearchResult, error) {
	var data map[string]json.RawMessage

```

1. 在同一个文件中,将 `RankingsPlayback` 更新为使用 `normalizeZone` 处理其 `filterBy`(或等价)逻辑,用对 `normalizeZone(...)` 的调用替换重复的 `if z, ok := Zones[...] { strconv.Itoa(z) }` 代码块。
2. 确保在 `internal/javdb/appapi/rankings.go` 文件顶部导入了 `strconv`(如果尚未导入),因为 `normalizeZone` 依赖 `strconv.Itoa`。
</issue_to_address>

### Comment 2
<location path="internal/cli/rankings_cmd.go" line_range="102" />
<code_context>
 				return err
 			}
-			res, err := c.RankingsActors(context.Background(), javdb.ActorPeriod(period))
+			res, err := c.RankingsActors(context.Background(), javdb.RankingPeriod(period))
 			if err != nil {
 				return fmt.Errorf("rankings failed: %w", err)
</code_context>
<issue_to_address>
**suggestion:** 当 `RankingsActors` 本身也会对 period 做归一化时,从 CLI 传入 `RankingPeriod(period)` 可能会让人困惑。

CLI 已经通过 `javdb.RankingPeriod` 对 `period` 做了归一化,而 `RankingsActors` 在内部也会应用 `RankingPeriod`。这种重复归一化会让各层期望的 period 格式(`day|week|month` vs. `daily|weekly|monthly`)变得不清晰。请合并这一职责——要么在 actors 的 CLI 层去掉归一化,要么在 app API 层移除归一化,并清晰地文档化每一层期望的 `period` 格式。

建议实现:

```golang
			// CLI 传入原始 period("day|week|month"),RankingsActors
			// 在内部通过 javdb.RankingPeriod 负责归一化。
			res, err := c.RankingsActors(context.Background(), period)

```

1. 确保 `RankingsActors` 在内部调用 `javdb.RankingPeriod`(或等价逻辑),这样归一化职责就明确地归属于 app API 这一层。
2. 如果其他 CLI 命令(例如电影排行榜)也会把 `javdb.RankingPeriod(period)` 传入在 app 层自身会做归一化的排行榜函数,请在这些地方做同样的调整以保持一致性。
3. 考虑在 `RankingsActors` 以及 CLI 的 `period` 标志上添加简短的文档注释,说明 CLI 使用 `day|week|month`,而 app 层负责转换为 `daily|weekly|monthly`。
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得我们的代码审查对你有帮助,请考虑分享它 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English

Hey - I've found 2 issues, and left some high level feedback:

  • The CLI now calls javdb.RankingPeriod while the app API client also applies RankingPeriod internally, which makes the period mapping redundant; consider passing the raw CLI value through and centralizing the mapping in one layer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The CLI now calls `javdb.RankingPeriod` while the app API client also applies `RankingPeriod` internally, which makes the period mapping redundant; consider passing the raw CLI value through and centralizing the mapping in one layer.

## Individual Comments

### Comment 1
<location path="internal/javdb/appapi/rankings.go" line_range="64-65" />
<code_context>

 // RankingsMovies GET /api/v1/rankings
 func (c *Client) RankingsMovies(type_, period string) (SearchResult, error) {
+	t := type_
+	if z, ok := Zones[type_]; ok {
+		t = strconv.Itoa(z)
+	}
</code_context>
<issue_to_address>
**suggestion:** Zone-to-int mapping for `type_` is duplicated and could be centralized.

The `type_` → `Zones` → `strconv.Itoa` logic here mirrors the `filterBy` handling in `RankingsPlayback`. Please extract a shared helper (e.g. `normalizeZone(string) string`) and use it in both places to remove duplication and keep the zone normalization consistent if the mapping changes.

Suggested implementation:

```golang
func normalizeZone(zone string) string {
	if z, ok := Zones[zone]; ok {
		return strconv.Itoa(z)
	}
	return zone
}

// RankingsMovies GET /api/v1/rankings
func (c *Client) RankingsMovies(type_, period string) (SearchResult, error) {
	t := normalizeZone(type_)

```

```golang
	var data map[string]json.RawMessage
	if err := c.GetJSON("/api/v1/rankings", map[string]string{
		"type": t, "period": RankingPeriod(period),
	}, &data); err != nil {
		return nil, err
	}
func (c *Client) RankingsActors(period string) (SearchResult, error) {
	var data map[string]json.RawMessage

```

1. In this same file, update `RankingsPlayback` to use `normalizeZone` for its `filterBy` (or equivalent) logic, replacing the duplicated `if z, ok := Zones[...] { strconv.Itoa(z) }` block with a `normalizeZone(...)` call.
2. Ensure `strconv` is imported at the top of `internal/javdb/appapi/rankings.go` (if it is not already), since `normalizeZone` depends on `strconv.Itoa`.
</issue_to_address>

### Comment 2
<location path="internal/cli/rankings_cmd.go" line_range="102" />
<code_context>
 				return err
 			}
-			res, err := c.RankingsActors(context.Background(), javdb.ActorPeriod(period))
+			res, err := c.RankingsActors(context.Background(), javdb.RankingPeriod(period))
 			if err != nil {
 				return fmt.Errorf("rankings failed: %w", err)
</code_context>
<issue_to_address>
**suggestion:** Passing `RankingPeriod(period)` into `RankingsActors` while `RankingsActors` also normalizes period is potentially confusing.

The CLI already normalizes `period` via `javdb.RankingPeriod`, and `RankingsActors` also applies `RankingPeriod` internally. This duplicated normalization obscures which layer expects `day|week|month` vs. `daily|weekly|monthly`. Please consolidate the responsibility—either drop the CLI-side normalization for actors or remove it from the app API and clearly document the expected `period` format at each layer.

Suggested implementation:

```golang
			// The CLI passes the raw period ("day|week|month") and RankingsActors
			// is responsible for normalizing it via javdb.RankingPeriod internally.
			res, err := c.RankingsActors(context.Background(), period)

```

1. Ensure `RankingsActors` internally calls `javdb.RankingPeriod` (or equivalent) so the normalization responsibility clearly resides in the app API layer.
2. If other CLI commands (e.g. movie rankings) also pass `javdb.RankingPeriod(period)` into app-layer ranking functions that themselves normalize, apply the same adjustment there for consistency.
3. Consider adding brief documentation comments on `RankingsActors` and the CLI `period` flag to clarify that the CLI uses `day|week|month` while the app layer handles conversion to `daily|weekly|monthly`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread internal/javdb/appapi/rankings.go Outdated
Comment thread internal/cli/rankings_cmd.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sdk/rankings.go`:
- Around line 9-10: 保留 sdk 中公开的 ActorPeriod 废弃兼容函数,并将其实现委托给
RankingPeriod,使现有调用方继续编译;不要移除该别名,并按现有弃用约定标注其后续主版本删除计划。
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e7267e24-e2de-4929-b098-1362c6bef846

📥 Commits

Reviewing files that changed from the base of the PR and between fba0713 and 42ffd94.

📒 Files selected for processing (4)
  • internal/cli/rankings_cmd.go
  • internal/javdb/appapi/rankings.go
  • internal/javdb/appapi/rankings_test.go
  • sdk/rankings.go

Comment thread sdk/rankings.go

@FlanChanXwO FlanChanXwO left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

代码审查未发现阻塞问题。已核对排行榜 zone/period 映射、app API 与公开 SDK 边界、ActorPeriod 向后兼容别名及聚焦测试;本地 go test、race、vet、build、发布脚本、pre-commit 与 LSP 诊断均通过。文档由维护者在后续发布准备中同步。

@FlanChanXwO
FlanChanXwO merged commit 4f0f827 into FlanChanXwO:main Aug 9, 2026
13 checks passed
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