Skip to content

feat: bl user add/update/delete, recently-viewed-projects/wikis, star list/count#72

Merged
23prime merged 4 commits intomainfrom
feature/53-user-add-update-delete-recently-viewed-stars
Mar 16, 2026
Merged

feat: bl user add/update/delete, recently-viewed-projects/wikis, star list/count#72
23prime merged 4 commits intomainfrom
feature/53-user-add-update-delete-recently-viewed-stars

Conversation

@23prime
Copy link
Owner

@23prime 23prime commented Mar 16, 2026

Checklist

  • Target branch is main
  • Status checks are passing
  • Documentation updated if user-visible behavior changed (website/docs/, website/i18n/ja/, README.md)

Summary

  • bl user add — POST /api/v2/users (requires Space Admin)
  • bl user update <id> — PATCH /api/v2/users/{userId} (requires Space Admin)
  • bl user delete <id> — DELETE /api/v2/users/{userId} (requires Space Admin)
  • bl user recently-viewed-projects — GET /api/v2/users/myself/recentlyViewedProjects
  • bl user recently-viewed-wikis — GET /api/v2/users/myself/recentlyViewedWikis
  • bl user star list <id> — GET /api/v2/users/{userId}/stars
  • bl user star count <id> — GET /api/v2/users/{userId}/stars/count
  • Add RoleType ValueEnum (Administrator/Normal/Reporter/Viewer/GuestReporter/GuestViewer)

Reason for change

Implements Issue #53.

Changes

  • src/api/user.rs — new structs (RecentlyViewedProject, RecentlyViewedWiki, Star, StarCount) + 7 new BacklogClient methods + tests
  • src/api/mod.rs — trait methods + impls for all 7 methods
  • src/cmd/user/add.rs, update.rs, delete.rs — new command files
  • src/cmd/user/recently_viewed_projects.rs, recently_viewed_wikis.rs — new command files
  • src/cmd/user/star/list.rs, star/count.rs, star/mod.rs — new command files
  • src/cmd/user/mod.rs — updated re-exports
  • src/main.rsRoleType ValueEnum + UserCommands extended + UserStarCommands added
  • website/docs/commands.md + website/i18n/ja/.../commands.md — docs added, coverage table updated

Notes

POST/PATCH/DELETE commands were not tested against the real API (would affect real data).
GET commands verified against real API.

Closes #53

Copilot AI review requested due to automatic review settings March 16, 2026 12:09
@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

Warning

Rate limit exceeded

@23prime has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b79c7d09-df9a-4c46-824f-293f62a99211

📥 Commits

Reviewing files that changed from the base of the PR and between ba884db and 403d901.

📒 Files selected for processing (3)
  • src/cmd/user/star/list.rs
  • src/cmd/user/update.rs
  • src/main.rs
📝 Walkthrough

Walkthrough

Adds user-management and user-interaction features: new BacklogApi methods and types (users, recently viewed projects/wikis, stars), BacklogClient implementations, CLI commands (add/update/delete, recently-viewed, star list/count) with argument validation, wiring in main, tests, and documentation updates.

Changes

Cohort / File(s) Summary
API trait & types
src/api/mod.rs, src/api/user.rs
Extended BacklogApi with 7 new methods (add_user, update_user, delete_user, get_recently_viewed_projects, get_recently_viewed_wikis, get_user_stars, count_user_stars); added public types RecentlyViewedProject, RecentlyViewedWiki, Star, StarCount; BacklogClient forwards to concrete methods.
User commands (CRUD)
src/cmd/user/add.rs, src/cmd/user/update.rs, src/cmd/user/delete.rs
New CLI modules implementing add/update/delete user commands, argument structs (UserAddArgs, UserUpdateArgs, UserDeleteArgs), client wiring, JSON/text output and unit tests.
Recently-viewed commands
src/cmd/user/recently_viewed_projects.rs, src/cmd/user/recently_viewed_wikis.rs
New commands to fetch recently viewed projects/wikis with try_new validation, query param construction (count/offset/order), JSON/text output, and tests.
User stars commands
src/cmd/user/star/mod.rs, src/cmd/user/star/list.rs, src/cmd/user/star/count.rs
New star submodule with list and count commands, argument validation (UserStarListArgs, UserStarCountArgs), API calls to user stars endpoints, dual output modes, and tests.
Command module exports
src/cmd/user/mod.rs, src/cmd/user/star/mod.rs
Added module declarations and re-exports for new subcommands (add, delete, recently_viewed_projects, recently_viewed_wikis, star::{list,count}).
CLI wiring
src/main.rs
Added RoleType enum, extended UserCommands and UserStarCommands, added imports for new arg types, and updated dispatch to construct and forward new argument structs.
Docs & i18n
website/docs/commands.md, website/i18n/ja/.../commands.md
Added command usage/examples and marked the new user-related endpoints as implemented in endpoint-status tables.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as CLI (main.rs)
    participant Cmd as Command Module
    participant Config as Config Loader
    participant Client as BacklogClient
    participant API as BacklogApi

    User->>CLI: run `bl user add ...` (or update/delete/recently-viewed/star)
    CLI->>Cmd: construct argument struct (new / try_new)
    Cmd->>Config: load credentials & endpoint
    Config-->>Cmd: return Config
    Cmd->>Client: create BacklogClient(config)
    Cmd->>API: call BacklogApi::<method>(params) via BacklogClient
    Client->>API: forward to concrete client method
    API-->>Client: return Result<T> (User / list / count)
    Client-->>Cmd: return result
    Cmd->>Cmd: format output (JSON or text)
    Cmd-->>User: print output
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 I hopped through code with tiny paws,

Added users, stars, and recent views because,
CLI now sings and tests all pass,
A carrot-shaped commit — quick as a dash! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.93% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main feature additions: new user management commands (add/update/delete), recently-viewed items display, and star list/count functionality.
Description check ✅ Passed The description is directly related to the changeset, providing clear details on new commands, API endpoints, implementation scope, testing notes, and the issue being closed.
Linked Issues check ✅ Passed The PR implements all seven core coding objectives from issue #53: add/update/delete user commands, recently-viewed-projects/wikis commands, and star list/count commands. All required endpoints are implemented.
Out of Scope Changes check ✅ Passed The RoleType enum addition, user command structure changes, and documentation updates are directly tied to the issue objectives. The GET /api/v2/users/{userId}/icon endpoint from issue #53 is noted but not implemented, which is appropriate scope management.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/53-user-add-update-delete-recently-viewed-stars
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feature/53-user-add-update-delete-recently-viewed-stars
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new bl user subcommands to manage users (add/update/delete) and to retrieve user-related lists (recently viewed projects/wikis, stars list/count), wiring them through the API layer and documenting the new commands.

Changes:

  • Extend CLI (src/main.rs) with new user and user star subcommands plus a RoleType value enum.
  • Add new command implementations under src/cmd/user/* for user CRUD and the new GET endpoints.
  • Extend BacklogClient/BacklogApi with new user endpoints and update the command reference docs (EN/JA).

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
website/docs/commands.md Adds EN docs for new bl user commands and updates endpoint coverage table statuses.
website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md Adds JA docs for new bl user commands and updates endpoint coverage table statuses.
src/main.rs Adds RoleType ValueEnum and new clap subcommands/routes for user CRUD, recently-viewed, and stars.
src/cmd/user/mod.rs Registers and re-exports the new user command modules.
src/cmd/user/add.rs Implements bl user add command and unit tests with a mock API.
src/cmd/user/update.rs Implements bl user update command and unit tests with a mock API.
src/cmd/user/delete.rs Implements bl user delete command and unit tests with a mock API.
src/cmd/user/recently_viewed_projects.rs Implements bl user recently-viewed-projects and unit tests.
src/cmd/user/recently_viewed_wikis.rs Implements bl user recently-viewed-wikis and unit tests.
src/cmd/user/star/mod.rs Introduces user star module wiring.
src/cmd/user/star/list.rs Implements bl user star list and unit tests, including argument validation.
src/cmd/user/star/count.rs Implements bl user star count and unit tests.
src/api/user.rs Adds new API structs + BacklogClient methods for the new endpoints, with httpmock tests.
src/api/mod.rs Extends BacklogApi trait and forwards new methods in the BacklogClient impl.

You can also share your feedback on Copilot code review. Take the survey.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
src/cmd/user/add.rs (1)

76-80: Tests should assert the exact request payload sent to add_user.

Right now the mock ignores _params, so key-name regressions (e.g., mailAddress, roleType) won’t fail tests.

🧪 Suggested payload assertion pattern
 struct MockApi {
     user: Option<User>,
+    seen_params: std::cell::RefCell<Vec<(String, String)>>,
 }

 impl crate::api::BacklogApi for MockApi {
-    fn add_user(&self, _params: &[(String, String)]) -> anyhow::Result<User> {
+    fn add_user(&self, params: &[(String, String)]) -> anyhow::Result<User> {
+        *self.seen_params.borrow_mut() = params.to_vec();
         self.user.clone().ok_or_else(|| anyhow!("add failed"))
     }
 }

 #[test]
 fn add_with_text_output_succeeds() {
     let api = MockApi {
         user: Some(sample_user()),
+        seen_params: std::cell::RefCell::new(Vec::new()),
     };
     assert!(add_with(&args(false), &api).is_ok());
+    let sent = api.seen_params.borrow();
+    assert!(sent.iter().any(|(k, v)| k == "userId" && v == "john"));
+    assert!(sent.iter().any(|(k, v)| k == "mailAddress" && v == "john@example.com"));
+    assert!(sent.iter().any(|(k, v)| k == "roleType" && v == "2"));
 }

Also applies to: 106-127

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cmd/user/add.rs` around lines 76 - 80, The MockApi's BacklogApi::add_user
implementation ignores the incoming _params so tests won't catch payload
key/name regressions; update MockApi (the add_user method) to validate the exact
request payload by matching the passed params (e.g., convert &[(String,String)]
to a map or ordered vec) against the expected keys and values (including exact
key names like "mailAddress" and "roleType"), return the stored user on match
and return an error or panic with a clear message on mismatch; apply the same
change pattern to the other mock methods referenced (lines 106-127) so tests
assert precise payload structure rather than ignoring params.
src/cmd/user/delete.rs (1)

50-53: Strengthen tests by asserting the forwarded user_id.

Current MockApi::delete_user ignores its input, so a regression in ID wiring would not be caught.

🔍 Suggested test hardening
 struct MockApi {
     user: Option<User>,
+    called_user_id: std::cell::Cell<Option<u64>>,
 }

 impl crate::api::BacklogApi for MockApi {
-    fn delete_user(&self, _user_id: u64) -> anyhow::Result<User> {
+    fn delete_user(&self, user_id: u64) -> anyhow::Result<User> {
+        self.called_user_id.set(Some(user_id));
         self.user.clone().ok_or_else(|| anyhow!("delete failed"))
     }
 }

 #[test]
 fn delete_with_text_output_succeeds() {
     let api = MockApi {
         user: Some(sample_user()),
+        called_user_id: std::cell::Cell::new(None),
     };
     assert!(delete_with(&args(false), &api).is_ok());
+    assert_eq!(api.called_user_id.get(), Some(1));
 }

Also applies to: 73-94

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cmd/user/delete.rs` around lines 50 - 53, MockApi::delete_user currently
ignores its _user_id parameter so tests can't catch bad ID wiring; update
MockApi::delete_user (and other mocked methods noted around the 73-94 region) to
validate the incoming user_id against the expected value (e.g., stored
expected_user_id or record the last_received_user_id) and return an error if it
differs, or assert/compare in the mock before returning the cloned user—this
ensures tests fail when the forwarded user_id is incorrect.
src/cmd/user/star/count.rs (1)

59-67: Add tests that assert since/until query forwarding.

Because _params is ignored in the mock, regressions in query key/value construction won’t be detected.

Also applies to: 73-94

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cmd/user/star/count.rs` around lines 59 - 67, The MockApi's
count_user_stars currently ignores the _params so tests won't catch regressions;
update MockApi::count_user_stars to capture and validate the incoming params
(e.g., check for "since" and/or "until" keys or store the params into a public
field like last_params on MockApi) and return the existing StarCount result only
after verifying params or exposing them for assertions; apply the same change to
the other mocked methods in this impl (the similar block covering lines 73-94)
so tests can assert that query key/value forwarding works.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/cmd/user/add.rs`:
- Around line 76-80: The MockApi's BacklogApi::add_user implementation ignores
the incoming _params so tests won't catch payload key/name regressions; update
MockApi (the add_user method) to validate the exact request payload by matching
the passed params (e.g., convert &[(String,String)] to a map or ordered vec)
against the expected keys and values (including exact key names like
"mailAddress" and "roleType"), return the stored user on match and return an
error or panic with a clear message on mismatch; apply the same change pattern
to the other mock methods referenced (lines 106-127) so tests assert precise
payload structure rather than ignoring params.

In `@src/cmd/user/delete.rs`:
- Around line 50-53: MockApi::delete_user currently ignores its _user_id
parameter so tests can't catch bad ID wiring; update MockApi::delete_user (and
other mocked methods noted around the 73-94 region) to validate the incoming
user_id against the expected value (e.g., stored expected_user_id or record the
last_received_user_id) and return an error if it differs, or assert/compare in
the mock before returning the cloned user—this ensures tests fail when the
forwarded user_id is incorrect.

In `@src/cmd/user/star/count.rs`:
- Around line 59-67: The MockApi's count_user_stars currently ignores the
_params so tests won't catch regressions; update MockApi::count_user_stars to
capture and validate the incoming params (e.g., check for "since" and/or "until"
keys or store the params into a public field like last_params on MockApi) and
return the existing StarCount result only after verifying params or exposing
them for assertions; apply the same change to the other mocked methods in this
impl (the similar block covering lines 73-94) so tests can assert that query
key/value forwarding works.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 97bd9717-eb00-445a-9f80-9a5e9ed5d8c0

📥 Commits

Reviewing files that changed from the base of the PR and between a840d48 and 036a05a.

📒 Files selected for processing (14)
  • src/api/mod.rs
  • src/api/user.rs
  • src/cmd/user/add.rs
  • src/cmd/user/delete.rs
  • src/cmd/user/mod.rs
  • src/cmd/user/recently_viewed_projects.rs
  • src/cmd/user/recently_viewed_wikis.rs
  • src/cmd/user/star/count.rs
  • src/cmd/user/star/list.rs
  • src/cmd/user/star/mod.rs
  • src/cmd/user/update.rs
  • src/main.rs
  • website/docs/commands.md
  • website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md

23prime added 2 commits March 16, 2026 22:03
Addresses review comment: flags not shown in docs, hard to discover
Addresses review comment: empty PATCH should be rejected locally
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md (1)

1166-1167: Optional cleanup: avoid duplicated star mapping rows in JA coverage tables.

As with the English doc, listing the same endpoints in both Stars and Users sections may cause future status drift. A canonical section + cross-reference would reduce maintenance overhead.

Also applies to: 1207-1208

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md` around
lines 1166 - 1167, Remove the duplicated star endpoint rows from the Users
section in the Japanese commands doc (the table rows containing `bl user star
list <id> | GET /api/v2/users/{userId}/stars` and `bl user star count <id> | GET
/api/v2/users/{userId}/stars/count`) and instead add a single canonical source
of truth in the Stars section with a brief cross-reference note in the Users
section that points readers to the Stars section; update any nearby duplicate
rows at the other occurrence (the ones around the `1207-1208` equivalent) to
follow the same pattern so the JA table mirrors the EN structure and avoids
future drift.
website/docs/commands.md (1)

1162-1163: Consider using a single source-of-truth for user star endpoint coverage.

bl user star list/count are documented in both Stars and Users coverage tables. This is fine now, but it can drift during future updates. Consider keeping one canonical row set and linking from the other section.

Also applies to: 1203-1204

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@website/docs/commands.md` around lines 1162 - 1163, Choose one canonical
table for the user-star endpoints (either the Stars section or the Users
section) and remove the duplicate rows for `bl user star list <id>` and `bl user
star count <id>` from the other section; in that other section replace the
removed rows with a link to the canonical table (use the endpoint paths `GET
/api/v2/users/{userId}/stars` and `GET /api/v2/users/{userId}/stars/count` as
anchor targets or headings) so coverage is maintained without duplication —
update the duplicate occurrences (including the other instance referenced around
the same area) and ensure the canonical table has an anchor/id so the link
resolves.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@website/docs/commands.md`:
- Around line 1162-1163: Choose one canonical table for the user-star endpoints
(either the Stars section or the Users section) and remove the duplicate rows
for `bl user star list <id>` and `bl user star count <id>` from the other
section; in that other section replace the removed rows with a link to the
canonical table (use the endpoint paths `GET /api/v2/users/{userId}/stars` and
`GET /api/v2/users/{userId}/stars/count` as anchor targets or headings) so
coverage is maintained without duplication — update the duplicate occurrences
(including the other instance referenced around the same area) and ensure the
canonical table has an anchor/id so the link resolves.

In `@website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md`:
- Around line 1166-1167: Remove the duplicated star endpoint rows from the Users
section in the Japanese commands doc (the table rows containing `bl user star
list <id> | GET /api/v2/users/{userId}/stars` and `bl user star count <id> | GET
/api/v2/users/{userId}/stars/count`) and instead add a single canonical source
of truth in the Stars section with a brief cross-reference note in the Users
section that points readers to the Stars section; update any nearby duplicate
rows at the other occurrence (the ones around the `1207-1208` equivalent) to
follow the same pattern so the JA table mirrors the EN structure and avoids
future drift.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 74cf43b3-7145-4dbf-88ba-c5edf9a22300

📥 Commits

Reviewing files that changed from the base of the PR and between 036a05a and ba884db.

📒 Files selected for processing (2)
  • website/docs/commands.md
  • website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md

Addresses review comment: contradictory query params should be validated
@23prime 23prime merged commit a557204 into main Mar 16, 2026
11 checks passed
@23prime 23prime deleted the feature/53-user-add-update-delete-recently-viewed-stars branch March 16, 2026 13:24
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.

feat: bl user add / update / delete + recently-viewed projects/wikis + stars

2 participants