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

Add atuin stats --filter-mode #1737

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

drbrain
Copy link
Contributor

@drbrain drbrain commented Feb 20, 2024

This adds atuin stats --filter-mode which takes the same options as atuin search --filter-mode. It allows filtering atuin stats output.

To accomplish this Database::list() now has an optional range argument and adds a WHERE clause matching Database::range().

Full output:

❯ cargo run --bin atuin -- stats
[▮▮▮▮▮▮▮▮▮▮] 4334 cargo nextest
[▮▮▮▮▮▮▮   ] 3275 git status
[▮▮▮▮▮     ] 2190 cargo run
[▮▮▮▮▮     ] 2190 git diff
[▮▮▮▮      ] 2083 git commit
[▮▮▮▮      ] 1823 c
[▮▮▮       ] 1645 cargo b
[▮▮▮       ] 1482 git switch
[▮▮▮       ] 1406 nvim
[▮▮▮       ] 1386 ls
Total commands:   49595
Unique commands:  14105

Workspace output:

❯ cargo run --bin atuin -- stats --filter-mode workspace
[▮▮▮▮▮▮▮▮▮▮] 35 cargo nextest
[▮▮▮▮▮▮▮▮▮ ] 33 cargo run
[▮▮▮       ] 12 ssh
[▮▮        ] 10 git diff
[▮▮        ]  7 git push
[▮         ]  6 git commit
[▮         ]  6 nvim
[▮         ]  5 date
[▮         ]  5 cargo b
[▮         ]  5 git switch
Total commands:   166
Unique commands:  64

Workspace with date filter:

❯ cargo run --bin atuin -- stats --filter-mode workspace today
[▮▮▮▮▮▮▮▮▮▮] 31 cargo nextest
[▮▮▮       ] 12 cargo run
[▮         ]  5 date
[▮         ]  5 RUST_LOG=debug
[▮         ]  4 git diff
[          ]  2 git commit
[          ]  1 git push
[          ]  1 git status
[          ]  1 rm
Total commands:   62
Unique commands:  18

Checks

  • I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle
  • I have checked that there are no existing pull requests for the same thing

This allows filtering stats to global, host, session, directory, or
workspace like `atuin search`.

It only works when no period is specified.
`atuin stats` can now use `--filter-mode` with date ranges
@ellie
Copy link
Member

ellie commented Mar 1, 2024

Thank you, looks good. would it be possible to get a rebase?

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