Optimize bestFilterHeaderHeightQuery (#5223)

This commit is contained in:
Chris Stewart 2023-09-05 09:45:56 -05:00 committed by GitHub
parent c038d2fa3b
commit 0e2fddcc57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -156,13 +156,14 @@ case class CompactFilterHeaderDAO()(implicit
safeDatabase.run(bestFilterHeaderQuery).map(_.headOption)
}
private val bestFilterHeaderHeightQuery = {
bestFilterHeaderQuery.map(_.headOption.map(_.height))
private val bestFilterHeaderHeightQuery: Rep[Option[Int]] = {
table.map(_.height).max
}
def getBestFilterHeaderHeight: Future[Int] = {
safeDatabase.run(bestFilterHeaderHeightQuery).map { filterHeaderHeightOpt =>
filterHeaderHeightOpt.getOrElse(0)
safeDatabase.run(bestFilterHeaderHeightQuery.result).map {
filterHeaderHeightOpt =>
filterHeaderHeightOpt.getOrElse(0)
}
}