manager: Simplify very complex mermaid graphs
All checks were successful
/ build (push) Successful in 1m4s
All checks were successful
/ build (push) Successful in 1m4s
Forgejo has a limit of 5000 characters per mermaid graph. We started hitting this for some issues. Regenerate a somewhat simplified version of the subtree in this case which hopefully does not hit the same limit again.
This commit is contained in:
parent
42ec50cb64
commit
cc05ba7407
3 changed files with 39 additions and 17 deletions
|
|
@ -111,17 +111,33 @@ pub async fn update_bot_comment_from_subtree(
|
|||
subtree: &crate::tree::Subtree<'_>,
|
||||
hash: &str,
|
||||
) -> anyhow::Result<()> {
|
||||
let mermaid = subtree.to_mermaid(&ctx.repo_url.to_string());
|
||||
let mut mermaid = subtree.to_mermaid(&ctx.repo_url.to_string(), false);
|
||||
|
||||
let full_text = format!(
|
||||
r##"## Partial Techtree
|
||||
// When the mermaid graph gets too big, regenerate a simplified version.
|
||||
if mermaid.len() > 4990 {
|
||||
log::info!("Mermaid graph is too big, generating simplified version...");
|
||||
mermaid = subtree.to_mermaid(&ctx.repo_url.to_string(), true);
|
||||
}
|
||||
|
||||
let full_text = if mermaid.len() > 4990 {
|
||||
format!(
|
||||
r##"## Partial Techtree
|
||||
_Sorry, the partial techtree is still too big to be displayed for this element..._
|
||||
|
||||
<small>Digest: {hash}; Last Updated: {timestamp}</small>"##,
|
||||
timestamp = ctx.timestamp,
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
r##"## Partial Techtree
|
||||
```mermaid
|
||||
{mermaid}
|
||||
```
|
||||
|
||||
<small>Digest: {hash}; Last Updated: {timestamp}</small>"##,
|
||||
timestamp = ctx.timestamp,
|
||||
);
|
||||
timestamp = ctx.timestamp,
|
||||
)
|
||||
};
|
||||
|
||||
update_bot_comment(&ctx, id, full_text).await?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue