Skip to content

feat: add a helper for the most recent entries - #286

Open
HadesArchitect wants to merge 1 commit into
mainfrom
feat/recent-keyspaces
Open

feat: add a helper for the most recent entries#286
HadesArchitect wants to merge 1 commit into
mainfrom
feat/recent-keyspaces

Conversation

@HadesArchitect

@HadesArchitect HadesArchitect commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Several places want to show only the tail of a list — the last few keyspaces touched, the last few ids in a debug line. Pull that out so it is written once.

Call sites follow in the next PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of recent item lists by safely limiting results to the requested number while preserving their order.

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f0c8fc1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 974e12c1-8912-407b-b316-dae3d6376c71

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The Cassandra session package adds a private lastN helper for returning up to the last n string-slice entries.

Changes

Cassandra session utility

Layer / File(s) Summary
Add lastN slice helper
pkg/cassandra/session.go
Adds handling for non-positive limits, short slices, and suffix extraction while preserving entry order.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the addition of a helper for retrieving the most recent entries.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/recent-keyspaces

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

@HadesArchitect

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 2

🤖 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 `@pkg/cassandra/session.go`:
- Line 195: Resolve the unused private helper lastN before merging: either add
an appropriate caller in the same package or add a same-package test that
exercises it; if neither is needed, remove or defer lastN until a caller is
ready so the unused lint check passes.
- Line 203: Update the suffix slice expression in the surrounding session method
to start at len(s)-n rather than len(s)-n-1, ensuring it returns exactly n
entries when the slice contains more than n elements.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 05d45c10-b755-40c4-8b96-b7ec6b26a26e

📥 Commits

Reviewing files that changed from the base of the PR and between cc6b21f and f0c8fc1.

📒 Files selected for processing (1)
  • pkg/cassandra/session.go
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: Build, lint and unit tests
  • GitHub Check: compatibilitycheck
🧰 Additional context used
📓 Path-based instructions (1)
pkg/**

⚙️ CodeRabbit configuration file

Go backend using the Grafana backend plugin SDK and the gocql driver. Check for Cassandra query safety, connection/session lifecycle, and TLS handling.

Files:

  • pkg/cassandra/session.go
🪛 golangci-lint (2.12.2)
pkg/cassandra/session.go

[error] 195-195: func lastN is unused

(unused)

Comment thread pkg/cassandra/session.go
Comment thread pkg/cassandra/session.go
return s
}

return s[len(s)-n-1:]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Fix the suffix start index.

Use len(s)-n, not len(s)-n-1. The current code returns n+1 entries when the slice is longer than n.

Proposed fix
-	return s[len(s)-n-1:]
+	return s[len(s)-n:]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return s[len(s)-n-1:]
return s[len(s)-n:]
🤖 Prompt for 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.

In `@pkg/cassandra/session.go` at line 203, Update the suffix slice expression in
the surrounding session method to start at len(s)-n rather than len(s)-n-1,
ensuring it returns exactly n entries when the slice contains more than n
elements.

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.

1 participant