0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 00:02:34 +01:00

modules/web_hook: Aggregate status updates on cancel to reduce edit load.

This commit is contained in:
Jason Volk 2023-04-09 15:21:59 -07:00
parent 715f21564e
commit c8ff5bbc37

View file

@ -1174,11 +1174,35 @@ github_handle__workflow_job(std::ostream &out,
})
};
const fmt::bsprintf<512> expect_unmodified
{
"%s%s</a>",
string_view{expect},
annote(workflow_job),
};
bool modified
{
!tokens(td, ""_sv, [&]
(const string_view &cell)
{
if(!startswith(cell, expect))
return true;
return cell == expect_unmodified; // return false for found
})
};
const bool cancelled
{
json::string(workflow_job["conclusion"]) == "cancelled"
};
string_view tab;
tab = ircd::strlcpy(buf, view(heading, headbuf));
tab = ircd::strlcat(buf, "<table><tr><td>");
if(exists)
if(exists && modified && !cancelled)
tokens(td, ""_sv, [&]
(const string_view &cell)
{
@ -1196,7 +1220,8 @@ github_handle__workflow_job(std::ostream &out,
tab = ircd::strlcat(buf, "</a>");
tab = ircd::strlcat(buf, ""_sv);
});
else
if(!exists || (modified && cancelled))
github_run_for_each_jobs(github_repopath(content), run_id, [&]
(const json::object &workflow_job)
{
@ -1209,9 +1234,12 @@ github_handle__workflow_job(std::ostream &out,
tab = ircd::strlcat(buf, annote(workflow_job));
tab = ircd::strlcat(buf, "</a>");
tab = ircd::strlcat(buf, ""_sv);
modified = true;
return true;
});
if(modified)
{
tab = ircd::strlcat(buf, "</td></tr></table>");
m::message(_webhook_room, _webhook_user, json::members
@ -1234,6 +1262,7 @@ github_handle__workflow_job(std::ostream &out,
}}
});
}
}
else if(json::string(workflow_job["conclusion"]) != "skipped")
{
string_view tab;