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 support for filtering by language type #208

Merged
merged 9 commits into from
May 3, 2023

Conversation

elliotwutingfeng
Copy link
Contributor

@elliotwutingfeng elliotwutingfeng commented Apr 30, 2023

Closes #6

Closes #4

You can choose to count lines only for specific language type(s), by using the ?type= query string. Languages are to be separated by a comma.

For example,

https://tokei.rs/b1/github/XAMPPRocky/tokei?type=JSON,Rust,Markdown
  • Unsupported languages are ignored.
  • Leaving ?type= blank leads to the default behavior of counting lines for all supported languages.

Live Demo

lines of json

lines of json and rust

lines of json, rust, and markdown

all lines

@elliotwutingfeng elliotwutingfeng marked this pull request as draft May 1, 2023 13:25
@XAMPPRocky
Copy link
Owner

Thank you for your PR! Is there a reason you've marked it as a draft?

@elliotwutingfeng
Copy link
Contributor Author

elliotwutingfeng commented May 1, 2023

Thank you for your PR! Is there a reason you've marked it as a draft?

No problem! This PR currently works, however, the caching of results for unique combinations of commit SHA hash and the ?type= values would lead to multiple git clones for the same SHA hash.

This would get worse if ?exclude= were to be implemented, which I am interested in working on.

I am thinking of caching results for the SHA hash only, and filtering by language type afterwards (filtering is cheap).

What do you think? Or alternatively I'll make this optimisation in a later PR.

@XAMPPRocky
Copy link
Owner

I am thinking of caching results for the SHA hash only, and filtering by language type afterwards (filtering is cheap).

I think that's the right approach, reducing cloning is critical since RAM is quite limited on the VPS machine.

@elliotwutingfeng elliotwutingfeng marked this pull request as ready for review May 2, 2023 08:11
@elliotwutingfeng
Copy link
Contributor Author

I've reverted the caching to SHA hash only.

@XAMPPRocky
Copy link
Owner

Thank you for your PR!

@XAMPPRocky XAMPPRocky merged commit f97d65b into XAMPPRocky:master May 3, 2023
@elliotwutingfeng elliotwutingfeng deleted the types branch May 3, 2023 07:04
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.

Badges: add filter ?type=Markdown,Rust Feature request: support by-language breakdown
2 participants