Skip to content
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

Refactor backgrounds tasks for better visibility #926

Merged
merged 32 commits into from
Jun 6, 2024
Merged
Prev Previous commit
Next Next commit
wip
mbryzek committed Jun 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6263686a5bb26290cea61aa41a8d685fe1a9f800
7 changes: 5 additions & 2 deletions api/app/invariants/CheckInvariants.scala
Original file line number Diff line number Diff line change
@@ -15,7 +15,9 @@ class CheckInvariants @Inject() (
def process(): Unit = {
val results = invariants.all.map { i =>
val count = database.withConnection { c =>
i.query.as(SqlParser.long(1).*)(c).headOption.getOrElse(0L)
i.query
.withDebugging()
.as(SqlParser.long(1).*)(c).headOption.getOrElse(0L)
}
InvariantResult(i, count)
}
@@ -24,8 +26,9 @@ class CheckInvariants @Inject() (

private[this] case class InvariantResult(invariant: Invariant, count: Long)
private[this] def sendResults(results: Seq[InvariantResult]): Unit = {
val (_, withErrors) = results.partition(_.count == 0)
val (noErrors, withErrors) = results.partition(_.count == 0)

println(s"# Invariants checked with no errors: ${noErrors.length}")
if (withErrors.nonEmpty) {
val subject = if (withErrors.length == 1) {
"1 Error"