Skip to content

feat(sync):daemon support for advanced sync #528

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

0xbrayo
Copy link
Member

@0xbrayo 0xbrayo commented Apr 15, 2025

Important

Adds advanced sync options to aw-sync daemon, including bucket selection, start date, and database file specification, with updated CLI and documentation.

  • Behavior:
    • Adds advanced sync options to aw-sync daemon, allowing specification of buckets, start_date, and sync_db.
    • Introduces daemon_advanced() in main.rs for handling advanced sync logic.
  • CLI Options:
    • New options in Commands::Daemon for --advanced, --buckets, --start-date, and --sync-db.
    • Updates README.md with examples and descriptions of new options.
  • Misc:
    • Updates comments in main.rs to reflect completed tasks.

This description was created by Ellipsis for 6241a4a. It will automatically update as commits are pushed.

@0xbrayo
Copy link
Member Author

0xbrayo commented Apr 15, 2025

Should we make the default, syncing all buckets?

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 6241a4a in 2 minutes and 46 seconds

More details
  • Looked at 163 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 8 drafted comments based on config settings.
1. aw-sync/README.md:25
  • Draft comment:
    Clarify the expected format for --start-date (YYYY-MM-DD) and that --buckets must be comma‐separated. This will help users avoid format mistakes.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is purely informative, providing guidance on how to use certain command-line options. It doesn't suggest a code change or ask for clarification on the code itself. It violates the rule against making purely informative comments.
2. aw-sync/src/main.rs:163
  • Draft comment:
    The comment states the default subcommand is 'Sync', but the code defaults to 'Daemon'. Update the comment to match the implementation.
  • Reason this comment was not posted:
    Comment was on unchanged code.
3. aw-sync/README.md:25
  • Draft comment:
    Consider adding an example for the --sync-db option usage (e.g. a valid absolute path) for clarity.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    While adding an example path could be helpful, the current description is already clear that it's for specifying a database file within the sync directory. The sync directory location is already explained elsewhere in the README (default ~/ActivityWatchSync). Adding an absolute path example could actually be misleading since it should be relative to the sync directory.
    The comment might have a point that concrete examples help users understand options better. The current description could be unclear about what constitutes a valid database filename.
    However, the existing description is sufficient given that it's clear the file should be in the sync directory, and database filenames are a basic concept. An absolute path example could mislead users about where the file should be located.
    The comment should be deleted as the current documentation is clear enough and adding an absolute path example could cause confusion about the expected file location.
4. aw-sync/src/main.rs:297
  • Draft comment:
    The termination signal (ctrlc) handling logic is duplicated in both daemon() and daemon_advanced(). Consider refactoring this into a helper to reduce repetition.
  • Reason this comment was not posted:
    Marked as duplicate.
5. aw-sync/src/main.rs:218
  • Draft comment:
    The sync_db path validation logic is repeated both in the SyncAdvanced branch and in daemon_advanced(). Consider extracting this validation into a helper function for maintainability.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
6. aw-sync/src/main.rs:265
  • Draft comment:
    The hard-coded 300-second timeout is used in multiple places. Consider extracting it into a named constant for clarity and easier modifications.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
7. aw-sync/README.md:82
  • Draft comment:
    There's an inconsistency in the casing of 'GDrive'. In line 6 it appears as 'GDrive' and in line 82 it's written as 'Gdrive'. It would be best to standardize the naming.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
8. aw-sync/src/main.rs:241
  • Draft comment:
    Typographical error: 'wiggleroom' should be corrected to 'wiggle room' for clarity in the comment.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_CjHolVl5LPjcTWIQ


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

) -> Result<(), Box<dyn Error>> {
let (tx, rx) = channel();

ctrlc::set_handler(move || {
Copy link

Choose a reason for hiding this comment

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

The ctrlc handler setup code is duplicated in both daemon() and daemon_advanced(). Consider refactoring this common logic into a helper function to reduce duplication.

if let Some(db_path) = &sync_db {
info!("Using sync db: {}", &db_path.display());

if !db_path.is_absolute() {
Copy link

Choose a reason for hiding this comment

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

The sync_db path validation logic is duplicated in both SyncAdvanced and daemon_advanced. Consider extracting this into a separate helper function to improve maintainability.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it's worth atp, never going to reuse/rewrite any other time.

aw-sync

# Advanced sync daemon with custom options
aw-sync daemon --advanced --buckets "aw-watcher-window,aw-watcher-afk" --start-date "2024-01-01"
Copy link
Member

Choose a reason for hiding this comment

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

The --advanced flag seems a bit redundant.

Seems like aw-sync daemon --buckets "aw-watcher-window,aw-watcher-afk" would be a valid command, but will silently not respect the cli params without --advanced.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had misread the comment previously. I guess the --advanced is redundant, can be inferred whenever there extra flags.

@0xbrayo 0xbrayo force-pushed the polish-sync branch 3 times, most recently from 0184b97 to c2380ec Compare April 18, 2025 12:28
Copy link

codecov bot commented Apr 18, 2025

Codecov Report

Attention: Patch coverage is 0% with 49 lines in your changes missing coverage. Please review.

Project coverage is 69.75%. Comparing base (656f3c9) to head (fba2d60).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
aw-sync/src/main.rs 0.00% 46 Missing ⚠️
aw-sync/src/sync.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #528      +/-   ##
==========================================
- Coverage   70.81%   69.75%   -1.07%     
==========================================
  Files          51       51              
  Lines        2916     2959      +43     
==========================================
- Hits         2065     2064       -1     
- Misses        851      895      +44     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines 64 to 67
/// Use advanced sync mode
/// (automatically enabled when any advanced options are provided)
#[clap(long)]
advanced: bool,
Copy link
Member

Choose a reason for hiding this comment

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

Can be removed now

Copy link
Member Author

Choose a reason for hiding this comment

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

Necessary for syncing all buckets by default, though I can remove it and use something like --buckets * as an alternative or just sync all buckets by default, resorting to syncing specific buckets when it is specified.

@0xbrayo 0xbrayo force-pushed the polish-sync branch 2 times, most recently from 0ba4d07 to 7c6dd44 Compare April 23, 2025 13:03
@0xbrayo
Copy link
Member Author

0xbrayo commented Apr 23, 2025

Sync all buckets by default now, accepts --buckets * for explicit syncing but it's not necessary.

@ErikBjare
Copy link
Member

Yeah I think it's unnecessary, using * might be confusing if people forget to quote it (glob expansion).

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