XAMPPRocky / tokei_rs

The tokei.rs server code.
Apache License 2.0
57 stars 11 forks source link

Add support for filtering by language type #208

Closed elliotwutingfeng closed 1 year ago

elliotwutingfeng commented 1 year ago

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

Live Demo

lines of json

lines of json and rust

lines of json, rust, and markdown

all lines

XAMPPRocky commented 1 year ago

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

elliotwutingfeng commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

I've reverted the caching to SHA hash only.

XAMPPRocky commented 1 year ago

Thank you for your PR!