Skip to content

Prevent report from exceeding maximum comment length #11

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

Merged
merged 1 commit into from
Dec 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions reportsizedeltas/reportsizedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ def generate_report(self, sketches_reports):
Keyword arguments:
sketches_reports -- list of sketches_reports containing the data to generate the deltas report from
"""
# From https://github.community/t/maximum-length-for-the-comment-body-in-issues-and-pr/148867/2
# > PR body/Issue comments are still stored in MySQL as a mediumblob with a maximum value length of 262,144.
# > This equals a limit of 65,536 4-byte unicode characters.
maximum_report_length = 262144

fqbn_column_heading = "Board"

# Generate summary report data
Expand Down Expand Up @@ -395,21 +400,27 @@ def generate_report(self, sketches_reports):
report_markdown = report_markdown + generate_markdown_table(row_list=summary_report_data) + "\n"

# Add full table
report_markdown = (report_markdown
+ "<details>\n"
"<summary>Click for full report table</summary>\n\n")
report_markdown = (report_markdown
+ generate_markdown_table(row_list=full_report_data)
+ "\n</details>\n\n")

# Add full CSV
report_markdown = (report_markdown
+ "<details>\n"
"<summary>Click for full report CSV</summary>\n\n"
"```\n")
report_markdown = (report_markdown
+ generate_csv_table(row_list=full_report_data)
+ "```\n</details>")
report_markdown_with_table = (report_markdown
+ "<details>\n"
"<summary>Click for full report table</summary>\n\n")
report_markdown_with_table = (report_markdown_with_table
+ generate_markdown_table(row_list=full_report_data)
+ "\n</details>\n\n")

if len(report_markdown_with_table) < maximum_report_length:
report_markdown = report_markdown_with_table

# Add full CSV
report_markdown_with_csv = (report_markdown
+ "<details>\n"
"<summary>Click for full report CSV</summary>\n\n"
"```\n")
report_markdown_with_csv = (report_markdown_with_csv
+ generate_csv_table(row_list=full_report_data)
+ "```\n</details>")

if len(report_markdown_with_csv) < maximum_report_length:
report_markdown = report_markdown_with_csv

logger.debug("Report:\n" + report_markdown)
return report_markdown
Expand Down