Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Todo sync now handles priorty correctly #203

Merged
merged 1 commit into from
Oct 28, 2024
Merged

Todo sync now handles priorty correctly #203

merged 1 commit into from
Oct 28, 2024

Conversation

rprouse
Copy link
Owner

@rprouse rprouse commented Oct 28, 2024

Fixes #194

Summary by CodeRabbit

  • New Features

    • Updated version number to 6.3.2 for the Guppi command line utility.
    • Enhanced task management by incorporating priority information in task titles.
  • Improvements

    • Changed default command-line arguments for launching the application from "bills all" to "todo sync," reflecting a new focus on task synchronization.
  • Bug Fixes

    • Improved task querying functionality by modifying how tasks are processed in the TodoService.

Copy link

coderabbitai bot commented Oct 28, 2024

Walkthrough

The changes in this pull request involve updates to three main files: the project file Guppi.Console.csproj, which reflects a version increment from 6.3.1 to 6.3.2; the launchSettings.json file, where the commandLineArgs property is modified from "bills all" to "todo sync"; and the TodoService.cs file, which introduces logic to handle task priorities more effectively. The modifications enhance task representation and adjust the command-line behavior of the console application.

Changes

File Change Summary
Guppi.Console/Guppi.Console.csproj Version updated from 6.3.1 to 6.3.2.
Guppi.Console/Properties/launchSettings.json commandLineArgs updated from "bills all" to "todo sync".
Guppi.Core/Services/TodoService.cs Introduced logic to extract task priority from the title; modified GetTaskListFromTodoTxt method implementation.

Assessment against linked issues

Objective Addressed Explanation
Add task to google with a priority like (B) dry herbs @home (#194) It's unclear if the new priority handling meets the specified format.
Sync to local (#194)
The created date is added before the priority (#194) The implementation does not change the order of the created date and priority as expected.

Possibly related PRs

  • Download Enbridge bills #201: This PR updates the version number in Guppi.Console.csproj from 6.3.0 to 6.3.1, which is directly related to the version increment in the main PR from 6.3.1 to 6.3.2.

Poem

In the garden of tasks, with priorities bright,
A hop and a skip, we sync day and night.
From bills to todos, the changes take flight,
With versioning magic, our future looks right! 🐇✨


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

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.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d67b840 and b4cef95.

📒 Files selected for processing (3)
  • Guppi.Console/Guppi.Console.csproj (1 hunks)
  • Guppi.Console/Properties/launchSettings.json (1 hunks)
  • Guppi.Core/Services/TodoService.cs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Guppi.Console/Guppi.Console.csproj
🔇 Additional comments (1)
Guppi.Console/Properties/launchSettings.json (1)

5-5: LGTM! Development environment configuration aligned with feature work.

The updated command line arguments appropriately reflect the current development focus on todo synchronization, making it easier to test the priority handling fixes. Note that this change only affects the development environment and won't impact production behavior.

title = title.Substring(3).Trim();
}

string taskStr = $"{priority}{task.Updated.GetRfc3339Date().ToString("yyyy-MM-dd")} {title}";
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve task string formatting.

While the priority is now correctly placed before the date, the string construction could be improved.

Consider this more readable format using string interpolation:

-string taskStr = $"{priority}{task.Updated.GetRfc3339Date().ToString("yyyy-MM-dd")} {title}";
+string taskStr = $"{priority} {task.Updated.GetRfc3339Date():yyyy-MM-dd} {title}";

This change:

  • Adds a space between priority and date for better readability
  • Uses a cleaner date format syntax
  • Maintains compatibility with todo.txt format
📝 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
string taskStr = $"{priority}{task.Updated.GetRfc3339Date().ToString("yyyy-MM-dd")} {title}";
string taskStr = $"{priority} {task.Updated.GetRfc3339Date():yyyy-MM-dd} {title}";

Comment on lines +98 to +106
// Pull the priority out of the title
string priority = string.Empty;
string title = task.Title;
if (title.Length >= 3 && title[0] == '(' && title[2] == ')' && title[3] == ' ')
{
priority = title.Substring(0, 4);
title = title.Substring(3).Trim();
}

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enhance priority validation and extraction.

The priority extraction logic could be improved to handle edge cases and validate the priority format more strictly.

Consider applying these improvements:

 string priority = string.Empty;
 string title = task.Title;
-if (title.Length >= 3 && title[0] == '(' && title[2] == ')' && title[3] == ' ')
+if (title.Length >= 4 && title[0] == '(' && title[2] == ')' && title[3] == ' ')
 {
+    char priorityLetter = title[1];
+    if (priorityLetter >= 'A' && priorityLetter <= 'Z')
+    {
         priority = title.Substring(0, 4);
-        title = title.Substring(3).Trim();
+        title = title.Substring(4).Trim();
+    }
 }

This change:

  • Validates that priority letters are uppercase A-Z
  • Uses more accurate substring length (4 instead of 3)
  • Properly handles the space after priority
📝 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
// Pull the priority out of the title
string priority = string.Empty;
string title = task.Title;
if (title.Length >= 3 && title[0] == '(' && title[2] == ')' && title[3] == ' ')
{
priority = title.Substring(0, 4);
title = title.Substring(3).Trim();
}
// Pull the priority out of the title
string priority = string.Empty;
string title = task.Title;
if (title.Length >= 4 && title[0] == '(' && title[2] == ')' && title[3] == ' ')
{
char priorityLetter = title[1];
if (priorityLetter >= 'A' && priorityLetter <= 'Z')
{
priority = title.Substring(0, 4);
title = title.Substring(4).Trim();
}
}

Comment on lines +98 to +107
// Pull the priority out of the title
string priority = string.Empty;
string title = task.Title;
if (title.Length >= 3 && title[0] == '(' && title[2] == ')' && title[3] == ' ')
{
priority = title.Substring(0, 4);
title = title.Substring(3).Trim();
}

string taskStr = $"{priority}{task.Updated.GetRfc3339Date().ToString("yyyy-MM-dd")} {title}";
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Priority sync implementation is incomplete for local to Google direction

The code review reveals an asymmetric implementation of priority handling:

  • When syncing from Google to local (todo.txt), priorities are correctly extracted from the title and preserved in the format (X) YYYY-MM-DD task
  • When syncing from local to Google (line 89), the task text is sent directly to Google without preserving the priority format: var newTask = new Google.Apis.Tasks.v1.Data.Task { Title = task.Text };

This means priorities set in local todo.txt files will be lost when syncing to Google Tasks.

🔗 Analysis chain

Verify priority sync behavior in both directions.

The implementation looks good for handling priorities from Google Tasks to local todo.txt. However, we should verify the behavior in both directions.

Let's check for any existing priority-related tests:

Would you like me to help create test cases to verify:

  1. Syncing tasks with priorities from local to Google
  2. Handling malformed priority formats
  3. Priority preservation during round-trip sync

I'll search for priority handling and test implementations to verify the sync behavior in both directions. The previous search might have been too specific, so let's broaden it.


I need to verify how the task titles are handled in both sync directions to understand the complete priority sync implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for priority-related test cases
rg -l "priority.*test" --type cs

# Check for existing todo.txt test files
fd -e txt "todo.*test"

Length of output: 59


Script:

#!/bin/bash
# Let's try a broader search for priority-related code and tests
rg -i "priority" --type cs -A 3 -B 3

# Also search for task-related test files
fd -e cs "test"

# Look for any existing test classes
ast-grep --pattern 'class $_ { $$$ [TestMethod] $$$ }'

Length of output: 2226


Script:

#!/bin/bash
# Let's look for the complete TodoService implementation to understand the bidirectional sync
ast-grep --pattern 'class TodoService { $$$ }'

# Search for todo.txt related code
rg "todo.txt" --type cs -A 3 -B 3

# Look for task title handling in both directions
rg "Title" --type cs -A 3 -B 3 Guppi.Core/Services/TodoService.cs

Length of output: 3319

@rprouse rprouse merged commit 4ba5908 into main Oct 28, 2024
2 checks passed
@rprouse rprouse deleted the issue/194 branch October 28, 2024 16:54
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.

Todo sync with priority
1 participant