Skip to content

Conversation

Dav-14
Copy link
Contributor

@Dav-14 Dav-14 commented Feb 13, 2025

  • feat(ledger): fctl ledger logs list
  • feat: upgrade go version

@Dav-14 Dav-14 requested a review from a team as a code owner February 13, 2025 16:39
@Dav-14 Dav-14 force-pushed the feat/pla-140-featfctl-add-command-for-get-ledger-logs branch from f7438f7 to a7954d2 Compare February 13, 2025 16:46
Copy link
Contributor

coderabbitai bot commented Feb 13, 2025

Warning

Rate limit exceeded

@Dav-14 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 10 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 45f6b9c and 7f9bb6a.

⛔ Files ignored due to path filters (1)
  • go.mod is excluded by !**/*.mod
📒 Files selected for processing (1)
  • Earthfile (1 hunks)

Walkthrough

The pull request introduces logging functionality into the ledger CLI application. A new logs package is added with a file that implements log listing capabilities. This includes new types for managing state (pagination, time filtering) and a set of commands to list and manage logs. Additionally, the primary ledger command is updated to integrate the new logs command into its hierarchy, ensuring that users can interact with log management via the command-line interface.

Changes

File(s) Change Summary
cmd/ledger/logs/…/list.go and cmd/ledger/logs/…/root.go Added a new logs package with log listing functionality. Introduced ListStore & ListController types, functions for instantiation, command creation (NewListCommand), and methods for parsing inputs, error handling, and rendering.
cmd/ledger/root.go Modified to import the logs package and integrate the new logs command (NewLogsCommand) into the main ledger CLI command hierarchy.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant CLI as Command Line
    participant LC as ListController
    participant API as Ledger API
    participant PT as pterm Renderer

    U->>CLI: Execute "ledger logs list"
    CLI->>LC: Invoke Run() with parameters (pagination, time filters)
    LC->>API: Request logs with specified parameters
    API-->>LC: Return logs data and updated cursor
    LC->>PT: Call Render() to format logs output
    PT-->>CLI: Display formatted log table to user
Loading

Poem

I’m hopping through the code with delight,
Finding logs as clear as day and night.
Commands and controllers dance in a row,
With time filters and pages in a joyful flow.
I twitch my nose and celebrate this art—
A rabbit’s cheer from the heart!
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Dav-14 Dav-14 force-pushed the feat/pla-140-featfctl-add-command-for-get-ledger-logs branch from a7954d2 to 45f6b9c Compare February 13, 2025 16:47
Copy link
Contributor

@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.

Actionable comments posted: 0

🧹 Nitpick comments (3)
cmd/ledger/logs/list.go (3)

17-24: Fix typo in flag name constant.

There's a typo in the endTimeFLag constant name (capital 'L').

-	endTimeFLag   = "end-time"
+	endTimeFlag   = "end-time"

65-101: Add validation for time range.

The time parsing logic is correct, but there's no validation to ensure that start time is before end time when both are provided.

 	if endTime := fctl.GetString(cmd, endTimeFLag); endTime != "" {
 		str, err := time.Parse(timeRFC, endTime)
 		if err != nil {
 			return nil, fmt.Errorf(`invalid end time parsing with %s: %w`, timeRFC, err)
 		}
 		request.EndTime = &str
+		if request.StartTime != nil && !request.StartTime.Before(str) {
+			return nil, fmt.Errorf("start time must be before end time")
+		}
 	}

103-142: Consider enhancing table output.

The table rendering is functional but could be improved for better readability.

  1. Consider adding column alignment for better readability:
 	return pterm.DefaultTable.
 		WithHasHeader().
 		WithWriter(cmd.OutOrStdout()).
 		WithData(tableData).
+		WithRightAlignment().
 		Render()
  1. Consider adding color coding for different log types to improve visual distinction:
 		return []string{
 			log.Date.Format(timeRFC),
 			strconv.FormatInt(log.ID, 10),
-			string(log.Type),
+			pterm.LightYellow(string(log.Type)),
 			log.Hash,
 		}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e38d0a6 and 45f6b9c.

📒 Files selected for processing (3)
  • cmd/ledger/logs/list.go (1 hunks)
  • cmd/ledger/logs/root.go (1 hunks)
  • cmd/ledger/root.go (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Tests
🔇 Additional comments (4)
cmd/ledger/logs/root.go (1)

8-16: LGTM! Well-structured command setup.

The command is well-organized with clear aliases and description. The integration with the list command is properly handled.

cmd/ledger/root.go (1)

6-6: LGTM! Clean integration of logs command.

The logs command is properly imported and integrated into the ledger command hierarchy.

Also applies to: 28-28

cmd/ledger/logs/list.go (2)

26-44: LGTM! Clean store and controller implementation.

The store and controller structures are well-defined with clear separation of concerns.


46-59: LGTM! Well-structured command with clear flags.

The command setup is comprehensive with appropriate flags for pagination and time filtering.

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