-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 MAX_ROWS
option for CSV rendering
#30268
Conversation
I think fall back render is still useful? Or we can view it as non-render mode? |
The file will always render as a table until one of the limits is reached. If the entire table cannot be displayed, users will receive a warning with a link to the non-rendered file. |
bf85a26
to
1391d7a
Compare
Maybe a bit higher default will be good, I'm thinking maybe 5k or 10k lines. Is the UI still reasonable fast with 10k lines and let's say 10 columns? |
MAX_ROWS
option for CSV rendering
Updated PR title. The linked issue #29663 seems incorrect. Is there a actually relevant issue for this? |
Initially, I started looking for the code intending to fix that specific problem. However, since it was resolved with another solution, I suppose we could define it as an enhancement. Should I open a new issue? |
When the limit is 5k, seems to still have good performance! |
I find such behaviour inconsistent with code view where we also do no partial render when file is too large. And I think a partial render might potentially be misleading to the user thinking they see the whole file. So I say no to partial render :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea is good, but there are some problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the new changes, it looks much better.
In my mind, there are some nits, for example:
- variable naming (camelCase, but not
raw_link
, the lint also fails due to it) - path escaping (maybe it should use
PathEscapeSegments
) - it's better to add a test to ensure MaxRows really works (mock it to
MaxRows=2
)
(if you don't mind, I could also help to edit the PR to address these nits)
And since in the RC period, 1.22 only receives necessary backports, so I think this PR could be merged when 1.22 gets a stable release (just wait for some time)
Yes please :) |
Fixes go-gitea#29663 Previously, when a CSV file was larger than the limit, the render function lost its function to render the code. There were also multiple reads to the file, in order to determine its size and render or pre-render. This solution implements a new config variable MAX_ROWS, which corresponds to the “Maximum allowed rows to render CSV files. (0 for no limit)” and rewrites the Render function for CSV files in markup module. Now the render function only reads the file once, having MAX_FILE_SIZE+1 as a reader limit and MAX_ROWS as a row limit. When the file is larger than MAX_FILE_SIZE or has more rows than MAX_ROWS, it only renders until the limit, and displays a user-friendly warning informing that the rendered data is not complete, in the user's language. The warning: ![image](https://s3.amazonaws.com/i.snag.gy/ieROGx.jpg)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
- Removed tags from sanitizer rules; - The warning message now is a table (to reuse UI elements); - ctx.RelativePath escaped; - Implemented a panic catch when getting a translation error;
* origin/main: (231 commits) Allow including `Reviewed-on`/`Reviewed-by` lines for custom merge messages (go-gitea#31211) Add `MAX_ROWS` option for CSV rendering (go-gitea#30268) Update `golang.org/x/net` (go-gitea#31260) Add replacement module for `mholt/archiver` (go-gitea#31267) Fix Activity Page Contributors dropdown (go-gitea#31264) Optimize runner-tags layout to enhance visual experience (go-gitea#31258) fix: allow actions artifacts storage migration to complete succesfully (go-gitea#31251) Add `lint-go-gopls` (go-gitea#30729) Make blockquote attention recognize more syntaxes (go-gitea#31240) Fix admin oauth2 custom URL settings (go-gitea#31246) Replace `gt-word-break` with `tw-break-anywhere` (go-gitea#31183) Make pasted "img" tag has the same behavior as markdown image (go-gitea#31235) Remove .segment from .project-column (go-gitea#31204) Fix overflow on push notification (go-gitea#31179) Fix NuGet Package API for $filter with Id equality (go-gitea#31188) Fix overflow on notifications (go-gitea#31178) Update chroma to v2.14.0 (go-gitea#31177) Update air package path (go-gitea#31233) Bump `@github/relative-time-element` to v4.4.1 (go-gitea#31232) Add option for mailer to override mail headers (go-gitea#27860) ...
* giteaofficial/main: Fix and clean up `ConfirmModal` (go-gitea#31283) Enable poetry non-package mode (go-gitea#31282) fixed the dropdown menu for the top New button to expand to the left (go-gitea#31273) Optimize repo-list layout to enhance visual experience (go-gitea#31272) Allow including `Reviewed-on`/`Reviewed-by` lines for custom merge messages (go-gitea#31211) Add `MAX_ROWS` option for CSV rendering (go-gitea#30268) Update `golang.org/x/net` (go-gitea#31260) Add replacement module for `mholt/archiver` (go-gitea#31267) Fix Activity Page Contributors dropdown (go-gitea#31264)
This solution implements a new config variable MAX_ROWS, which corresponds to the “Maximum allowed rows to render CSV files. (0 for no limit)” and rewrites the Render function for CSV files in markup module. Now the render function only reads the file once, having MAX_FILE_SIZE+1 as a reader limit and MAX_ROWS as a row limit. When the file is larger than MAX_FILE_SIZE or has more rows than MAX_ROWS, it only renders until the limit, and displays a user-friendly warning informing that the rendered data is not complete, in the user's language.
Previously, when a CSV file was larger than the limit, the render function lost its function to render the code. There were also multiple reads to the file, in order to determine its size and render or pre-render.
The warning: