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
|
|
@ -51,6 +51,7 @@ impl Element {
|
|||
index: ElementIndex,
|
||||
role: Option<SubtreeElementRole>,
|
||||
repo_url: &str,
|
||||
simple: bool,
|
||||
) -> String {
|
||||
let Element {
|
||||
issue_number,
|
||||
|
|
@ -59,9 +60,13 @@ impl Element {
|
|||
status,
|
||||
} = self;
|
||||
|
||||
let label = format!(
|
||||
r##"<a href='{repo_url}/issues/{issue_number}' target='_blank'>#{issue_number}</a> | {status}\n<i>{ty}</i>\n<b>{description}</b>"##
|
||||
);
|
||||
let label = if simple {
|
||||
format!(r##"#{issue_number} | {status}\n<i>{ty}</i>\n<b>{description}</b>"##)
|
||||
} else {
|
||||
format!(
|
||||
r##"<a href='{repo_url}/issues/{issue_number}' target='_blank'>#{issue_number}</a> | {status}\n<i>{ty}</i>\n<b>{description}</b>"##
|
||||
)
|
||||
};
|
||||
|
||||
let class = match (role, status) {
|
||||
(Some(SubtreeElementRole::ElementOfInterest), _) => "eoi",
|
||||
|
|
@ -176,13 +181,13 @@ impl Tree {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn to_mermaid(&self, repo_url: &str) -> String {
|
||||
pub fn to_mermaid(&self, repo_url: &str, simple: bool) -> String {
|
||||
let mut mermaid = String::new();
|
||||
mermaid.push_str("flowchart BT\n");
|
||||
mermaid.push_str(&mermaid_classes());
|
||||
|
||||
for index in self.graph.node_indices() {
|
||||
mermaid.push_str(&self.graph[index].to_mermaid_node(index, None, repo_url));
|
||||
mermaid.push_str(&self.graph[index].to_mermaid_node(index, None, repo_url, simple));
|
||||
mermaid.push_str("\n");
|
||||
}
|
||||
|
||||
|
|
@ -300,18 +305,19 @@ impl<'a> Subtree<'a> {
|
|||
format!("{:?}", dot)
|
||||
}
|
||||
|
||||
pub fn to_mermaid(&self, repo_url: &str) -> String {
|
||||
pub fn to_mermaid(&self, repo_url: &str, simple: bool) -> String {
|
||||
let mut mermaid = String::new();
|
||||
mermaid.push_str("flowchart BT\n");
|
||||
mermaid.push_str(&mermaid_classes());
|
||||
|
||||
for index in self.graph.node_indices() {
|
||||
let node = &self.graph[index];
|
||||
mermaid.push_str(
|
||||
&node
|
||||
.element
|
||||
.to_mermaid_node(index, Some(node.role), repo_url),
|
||||
);
|
||||
mermaid.push_str(&node.element.to_mermaid_node(
|
||||
index,
|
||||
Some(node.role),
|
||||
repo_url,
|
||||
simple,
|
||||
));
|
||||
mermaid.push_str("\n");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue