Commit b27102c7 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Try with Either class

parent d4d307a2
...@@ -14,12 +14,17 @@ ...@@ -14,12 +14,17 @@
*/ */
package nl.lumc.sasc.biopet.pipelines.bammetrics package nl.lumc.sasc.biopet.pipelines.bammetrics
import java.io.{ File, PrintWriter } import java.io.{File, PrintWriter}
import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.core.report.{ ReportBuilderExtension, ReportBuilder, ReportPage, ReportSection } import nl.lumc.sasc.biopet.core.report.{ReportBuilder, ReportBuilderExtension, ReportPage, ReportSection}
import nl.lumc.sasc.biopet.utils.summary.{ Summary, SummaryValue } import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.rscript.{ StackedBarPlot, LinePlot } import nl.lumc.sasc.biopet.utils.rscript.{LinePlot, StackedBarPlot}
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Await
import scala.concurrent.duration.Duration
class BammetricsReport(val parent: Configurable) extends ReportBuilderExtension { class BammetricsReport(val parent: Configurable) extends ReportBuilderExtension {
def builder = BammetricsReport def builder = BammetricsReport
...@@ -52,23 +57,26 @@ object BammetricsReport extends ReportBuilder { ...@@ -52,23 +57,26 @@ object BammetricsReport extends ReportBuilder {
} }
/** Generates a page with alignment stats */ /** Generates a page with alignment stats */
def bamMetricsPage(summary: Summary, def bamMetricsPage(summary: SummaryDb,
sampleId: Option[String], sampleId: Option[Int],
libId: Option[String], libId: Option[Int],
metricsTag: String = "bammetrics") = { metricsTag: String = "bammetrics") = {
val wgsExecuted = summary.getValue(sampleId, libId, metricsTag, "stats", "wgs").isDefined //val pipelineId: Int = summary.getPipelineId(runId, metricsTag).map(_.get)
val rnaExecuted = summary.getValue(sampleId, libId, metricsTag, "stats", "rna").isDefined
val wgsExecuted = summary.getStatsSize(runId, Right(metricsTag), Some(Right("wgs")), sample = sampleId.map(Left(_)), library = libId.map(Left(_))) >= 1
val rnaExecuted = summary.getStatsSize(runId, Right(metricsTag), Some(Right("rna")), sample = sampleId.map(Left(_)), library = libId.map(Left(_))) >= 1
val insertsizeMetrics = summary.getStatKeys(runId, Right(metricsTag), Some(Right("CollectInsertSizeMetrics")),
sample = sampleId.map(Left(_)), library = libId.map(Left(_)), Map("metrics" -> List("metrics")))
.exists(_._2.isDefined)
val insertsizeMetrics = summary.getValue(sampleId, libId, metricsTag, "stats", "CollectInsertSizeMetrics", "metrics") match {
case Some(None) => false
case Some(_) => true
case _ => false
}
val targetSettings = summary.getSettingKeys(runId, Right(metricsTag),None, sample = sampleId.map(Left(_)), library = libId.map(Left(_)),
Map("amplicon_name" -> List("amplicon_name"), "roi_name" -> List("roi_name")))
val targets = ( val targets = (
summary.getValue(sampleId, libId, metricsTag, "settings", "amplicon_name"), targetSettings("amplicon_name"),
summary.getValue(sampleId, libId, metricsTag, "settings", "roi_name") targetSettings("roi_name")
) match { ) match {
case (Some(amplicon: String), Some(roi: List[_])) => amplicon :: roi.map(_.toString) case (Some(amplicon: String), Some(roi: List[_])) => amplicon :: roi.map(_.toString)
case (_, Some(roi: List[_])) => roi.map(_.toString) case (_, Some(roi: List[_])) => roi.map(_.toString)
...@@ -108,44 +116,43 @@ object BammetricsReport extends ReportBuilder { ...@@ -108,44 +116,43 @@ object BammetricsReport extends ReportBuilder {
*/ */
def alignmentSummaryPlot(outputDir: File, def alignmentSummaryPlot(outputDir: File,
prefix: String, prefix: String,
summary: Summary, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[String] = None): Unit = { sampleId: Option[Int] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv") val tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png") val pngFile = new File(outputDir, prefix + ".png")
val tsvWriter = new PrintWriter(tsvFile) val tsvWriter = new PrintWriter(tsvFile)
if (libraryLevel) tsvWriter.print("Library") else tsvWriter.print("Sample") if (libraryLevel) tsvWriter.print("Library") else tsvWriter.print("Sample")
tsvWriter.println("\tMapped\tDuplicates\tUnmapped\tSecondary") tsvWriter.println("\tMapped\tDuplicates\tUnmapped\tSecondary")
def getLine(summary: Summary, sample: String, lib: Option[String] = None): String = { val statsPaths = Map(
val mapped = new SummaryValue(List("bammetrics", "stats", "bamstats", "flagstats", "Mapped"), "Mapped" -> List("flagstats", "Mapped"),
summary, Some(sample), lib).value.getOrElse(0).toString.toLong "Duplicates" -> List("flagstats", "Duplicates"),
val duplicates = new SummaryValue(List("bammetrics", "stats", "bamstats", "flagstats", "Duplicates"), "All" -> List("flagstats", "All"),
summary, Some(sample), lib).value.getOrElse(0).toString.toLong "NotPrimaryAlignment" -> List("flagstats", "NotPrimaryAlignment")
val total = new SummaryValue(List("bammetrics", "stats", "bamstats", "flagstats", "All"), )
summary, Some(sample), lib).value.getOrElse(0).toString.toLong
val secondary = new SummaryValue(List("bammetrics", "stats", "bamstats", "flagstats", "NotPrimaryAlignment"), val pipelineId: Int = summary.getPipelineId(runId, "bammetrics").map(_.get)
summary, Some(sample), lib).value.getOrElse(0).toString.toLong val moduleId: Option[Int] = summary.getmoduleId(runId, "bamstats", pipelineId)
val results: Map[(Int, Option[Int]), Map[String, Option[Any]]] = if (libraryLevel) {
summary.getStatsForLibraries(runId = runId, pipelineName = "bammetrics", moduleName = Some("bamstats"), sampleId = sampleId, keyValues = statsPaths).map(x => (x._1._1, Some(x._1._2)) -> x._2)
} else summary.getStatsForSamples(runId, pipelineId, moduleId, sample = sampleId, keyValues = statsPaths).map(x => (x._1, None) -> x._2)
for (((s,l),result) <- results) {
val sampleName: String = summary.getSampleName(s).map(_.get)
val libName: Option[String] = l.flatMap(x => Await.result(summary.getLibraryName(x), Duration.Inf))
val sb = new StringBuffer() val sb = new StringBuffer()
if (lib.isDefined) sb.append(sample + "-" + lib.get + "\t") else sb.append(sample + "\t") if (libName.isDefined) sb.append(sampleName + "-" + libName.get + "\t") else sb.append(sampleName + "\t")
val mapped = ConfigUtils.any2long(result("Mapped"))
val duplicates = ConfigUtils.any2long(result("Duplicates"))
val total = ConfigUtils.any2long(result("All"))
val secondary = ConfigUtils.any2long(result("NotPrimaryAlignment"))
sb.append((mapped - duplicates - secondary) + "\t") sb.append((mapped - duplicates - secondary) + "\t")
sb.append(duplicates + "\t") sb.append(duplicates + "\t")
sb.append((total - mapped) + "\t") sb.append((total - mapped) + "\t")
sb.append(secondary) sb.append(secondary)
sb.toString tsvWriter.println(sb.toString)
}
if (libraryLevel) {
for (
sample <- summary.samples if sampleId.isEmpty || sample == sampleId.get;
lib <- summary.libraries(sample)
) {
tsvWriter.println(getLine(summary, sample, Some(lib)))
}
} else {
for (sample <- summary.samples if sampleId.isEmpty || sample == sampleId.get) {
tsvWriter.println(getLine(summary, sample))
}
} }
tsvWriter.close() tsvWriter.close()
...@@ -155,8 +162,8 @@ object BammetricsReport extends ReportBuilder { ...@@ -155,8 +162,8 @@ object BammetricsReport extends ReportBuilder {
plot.output = pngFile plot.output = pngFile
plot.ylabel = Some("Reads") plot.ylabel = Some("Reads")
if (libraryLevel) { if (libraryLevel) {
plot.width = Some(200 + (summary.libraries.filter(s => sampleId.getOrElse(s._1) == s._1).foldLeft(0)(_ + _._2.size) * 10)) plot.width = Some(200 + (libraries.filter(s => sampleId.getOrElse(s.id) == s.id).size) * 10)
} else plot.width = Some(200 + (summary.samples.count(s => sampleId.getOrElse(s) == s) * 10)) } else plot.width = Some(200 + (samples.count(s => sampleId.getOrElse(s) == s) * 10))
plot.title = Some("Aligned reads") plot.title = Some("Aligned reads")
plot.runLocal() plot.runLocal()
} }
...@@ -172,18 +179,27 @@ object BammetricsReport extends ReportBuilder { ...@@ -172,18 +179,27 @@ object BammetricsReport extends ReportBuilder {
*/ */
def insertSizePlot(outputDir: File, def insertSizePlot(outputDir: File,
prefix: String, prefix: String,
summary: Summary, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[String] = None, sampleId: Option[Int] = None,
libId: Option[String] = None): Unit = { libId: Option[Int] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv") val tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png") val pngFile = new File(outputDir, prefix + ".png")
def paths(name: String) = Map( val statsPaths = Map(
"insert_size" -> List("bammetrics", "stats", "CollectInsertSizeMetrics", "histogram", "insert_size"), "insert_size" -> List("histogram", "insert_size"),
name -> List("bammetrics", "stats", "CollectInsertSizeMetrics", "histogram", "All_Reads.fr_count") "All_Reads.fr_count" -> List("histogram", "All_Reads.fr_count")
) )
val pipelineId: Int = summary.getPipelineId(runId, "bammetrics").map(_.get)
val moduleId: Option[Int] = summary.getmoduleId(runId, "CollectInsertSizeMetrics", pipelineId)
val results: Map[(Int, Option[Int]), Map[String, Option[Array[Any]]]] = if (libraryLevel) {
summary.getStatsForLibraries(runId, pipelineId, moduleId, sampleId = sampleId, keyValues = statsPaths)
.map(x => (x._1._1, Some(x._1._2)) -> x._2.map(x => x._1 -> x._2.map(ConfigUtils.any2list(_).toArray)))
} else summary.getStatsForSamples(runId, pipelineId, moduleId, sample = sampleId, keyValues = statsPaths)
.map(x => (x._1, None) -> x._2.map(x => x._1 -> x._2.map(ConfigUtils.any2list(_).toArray)))
val tables = getSampleLibraries(summary, sampleId, libId, libraryLevel) val tables = getSampleLibraries(summary, sampleId, libId, libraryLevel)
.map { .map {
case (sample, lib) => case (sample, lib) =>
...@@ -200,10 +216,10 @@ object BammetricsReport extends ReportBuilder { ...@@ -200,10 +216,10 @@ object BammetricsReport extends ReportBuilder {
def mappingQualityPlot(outputDir: File, def mappingQualityPlot(outputDir: File,
prefix: String, prefix: String,
summary: Summary, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[String] = None, sampleId: Option[Int] = None,
libId: Option[String] = None): Unit = { libId: Option[Int] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv") val tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png") val pngFile = new File(outputDir, prefix + ".png")
...@@ -228,10 +244,10 @@ object BammetricsReport extends ReportBuilder { ...@@ -228,10 +244,10 @@ object BammetricsReport extends ReportBuilder {
def clippingPlot(outputDir: File, def clippingPlot(outputDir: File,
prefix: String, prefix: String,
summary: Summary, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[String] = None, sampleId: Option[Int] = None,
libId: Option[String] = None): Unit = { libId: Option[Int] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv") val tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png") val pngFile = new File(outputDir, prefix + ".png")
...@@ -265,10 +281,10 @@ object BammetricsReport extends ReportBuilder { ...@@ -265,10 +281,10 @@ object BammetricsReport extends ReportBuilder {
*/ */
def wgsHistogramPlot(outputDir: File, def wgsHistogramPlot(outputDir: File,
prefix: String, prefix: String,
summary: Summary, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[String] = None, sampleId: Option[Int] = None,
libId: Option[String] = None): Unit = { libId: Option[Int] = None): Unit = {
val tsvFile = new File(outputDir, prefix + ".tsv") val tsvFile = new File(outputDir, prefix + ".tsv")
val pngFile = new File(outputDir, prefix + ".png") val pngFile = new File(outputDir, prefix + ".png")
...@@ -302,7 +318,7 @@ object BammetricsReport extends ReportBuilder { ...@@ -302,7 +318,7 @@ object BammetricsReport extends ReportBuilder {
*/ */
def rnaHistogramPlot(outputDir: File, def rnaHistogramPlot(outputDir: File,
prefix: String, prefix: String,
summary: Summary, summary: SummaryDb,
libraryLevel: Boolean = false, libraryLevel: Boolean = false,
sampleId: Option[String] = None, sampleId: Option[String] = None,
libId: Option[String] = None): Unit = { libId: Option[String] = None): Unit = {
...@@ -328,20 +344,20 @@ object BammetricsReport extends ReportBuilder { ...@@ -328,20 +344,20 @@ object BammetricsReport extends ReportBuilder {
removeZero = true).runLocal() removeZero = true).runLocal()
} }
private def getSampleLibraries(summary: Summary, private def getSampleLibraries(summary: SummaryDb,
sampleId: Option[String] = None, sampleId: Option[Int] = None,
LibId: Option[String] = None, LibId: Option[Int] = None,
libraryLevel: Boolean = false): List[(String, Option[String])] = { libraryLevel: Boolean = false): List[(Int, Option[Int])] = {
if (LibId.isDefined) require(sampleId.isDefined) if (LibId.isDefined) require(sampleId.isDefined)
if (libraryLevel || LibId.isDefined) if (libraryLevel || LibId.isDefined)
for ((sample, libs) <- summary.libraries.toList; lib <- libs) yield (sample, Some(lib)) for ((sample, libs) <- summary.libraries.toList; lib <- libs) yield (sample, Some(lib))
else for ((sample, libs) <- summary.libraries.toList) yield (sample, None) else for ((sample, libs) <- summary.libraries.toList) yield (sample, None)
} }
def getTableFromSummary(summary: Summary, def getTableFromSummary(summary: SummaryDb,
paths: Map[String, List[String]], paths: Map[String, List[String]],
sampleId: Option[String] = None, sampleId: Option[Int] = None,
libId: Option[String] = None): Map[String, Array[Any]] = { libId: Option[Int] = None): Map[String, Array[Any]] = {
val pathValues: Map[String, Array[Any]] = paths.map { val pathValues: Map[String, Array[Any]] = paths.map {
case (key, path) => case (key, path) =>
val value = summary.getValueAsArray(sampleId, libId, path: _*) val value = summary.getValueAsArray(sampleId, libId, path: _*)
......
...@@ -17,13 +17,15 @@ package nl.lumc.sasc.biopet.core.report ...@@ -17,13 +17,15 @@ package nl.lumc.sasc.biopet.core.report
import java.io._ import java.io._
import nl.lumc.sasc.biopet.core.ToolCommandFunction import nl.lumc.sasc.biopet.core.ToolCommandFunction
import nl.lumc.sasc.biopet.utils.summary.db.Schema.{Library, Sample}
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import nl.lumc.sasc.biopet.utils.{IoUtils, Logging, ToolCommand} import nl.lumc.sasc.biopet.utils.{IoUtils, Logging, ToolCommand}
import org.broadinstitute.gatk.utils.commandline.Input import org.broadinstitute.gatk.utils.commandline.Input
import nl.lumc.sasc.biopet.utils.tryToParseNumber
import org.fusesource.scalate.{TemplateEngine, TemplateSource} import org.fusesource.scalate.{TemplateEngine, TemplateSource}
import scala.collection.mutable import scala.collection.mutable
import scala.concurrent.Await import scala.concurrent.{Await, Future}
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
import scala.language.postfixOps import scala.language.postfixOps
...@@ -72,6 +74,7 @@ trait ReportBuilderExtension extends ToolCommandFunction { ...@@ -72,6 +74,7 @@ trait ReportBuilderExtension extends ToolCommandFunction {
trait ReportBuilder extends ToolCommand { trait ReportBuilder extends ToolCommand {
implicit def toOption[T](x: T) : Option[T] = Option(x) implicit def toOption[T](x: T) : Option[T] = Option(x)
implicit def autoWait[T](x: Future[T]) : T = Await.result(x, Duration.Inf)
case class Args(summaryDbFile: File = null, case class Args(summaryDbFile: File = null,
outputDir: File = null, outputDir: File = null,
...@@ -115,21 +118,10 @@ trait ReportBuilder extends ToolCommand { ...@@ -115,21 +118,10 @@ trait ReportBuilder extends ToolCommand {
final def runId = setRunId final def runId = setRunId
private var setSampleCache: Map[String, Int] = _ private var _setSamples = Seq[Sample]()
final def samples = _setSamples
final def sampleCache = setSampleCache private var _setLibraries = Seq[Library]()
final def libraries = _setLibraries
private var setLibraryCache: Map[(String, String), Int] = _
final def libraryCache = setSampleCache
private var setPipelineCache: Map[String, Int] = _
final def pipelineCache = setPipelineCache
private var setModuleCache: Map[String, Int] = _
final def moduleCache = setModuleCache
/** default args that are passed to all page withing the report */ /** default args that are passed to all page withing the report */
def pageArgs: Map[String, Any] = Map() def pageArgs: Map[String, Any] = Map()
...@@ -137,9 +129,9 @@ trait ReportBuilder extends ToolCommand { ...@@ -137,9 +129,9 @@ trait ReportBuilder extends ToolCommand {
private var done = 0 private var done = 0
private var total = 0 private var total = 0
private var _sampleId: Option[String] = None private var _sampleId: Option[Int] = None
protected[report] def sampleId = _sampleId protected[report] def sampleId = _sampleId
private var _libId: Option[String] = None private var _libId: Option[Int] = None
protected[report] def libId = _libId protected[report] def libId = _libId
case class ExtFile(resourcePath: String, targetPath: String) case class ExtFile(resourcePath: String, targetPath: String)
...@@ -168,20 +160,26 @@ trait ReportBuilder extends ToolCommand { ...@@ -168,20 +160,26 @@ trait ReportBuilder extends ToolCommand {
require(cmdArgs.outputDir.exists(), "Output dir does not exist") require(cmdArgs.outputDir.exists(), "Output dir does not exist")
require(cmdArgs.outputDir.isDirectory, "Output dir is not a directory") require(cmdArgs.outputDir.isDirectory, "Output dir is not a directory")
setSummary = SummaryDb.openSqliteSummary(cmdArgs.summaryDbFile)
setRunId = cmdArgs.runId
cmdArgs.pageArgs.get("sampleId") match { cmdArgs.pageArgs.get("sampleId") match {
case Some(s: String) => case Some(s: String) =>
cmdArgs.pageArgs += "sampleId" -> Some(s) _sampleId = Await.result(summary.getSampleId(runId, s), Duration.Inf)
_sampleId = Some(s) cmdArgs.pageArgs += "sampleId" -> sampleId
case _ => case _ =>
} }
cmdArgs.pageArgs.get("libId") match { cmdArgs.pageArgs.get("libId") match {
case Some(l: String) => case Some(l: String) =>
cmdArgs.pageArgs += "libId" -> Some(l) _libId = Await.result(summary.getLibraryId(runId, sampleId.get, l), Duration.Inf)
_libId = Some(l) cmdArgs.pageArgs += "libId" -> libId
case _ => case _ =>
} }
_setSamples = Await.result(summary.getSamples(runId = Some(runId), sampleId = sampleId), Duration.Inf)
_setLibraries = Await.result(summary.getLibraries(runId = Some(runId), sampleId = sampleId, libId = libId), Duration.Inf)
logger.info("Copy Base files") logger.info("Copy Base files")
// Static files that will be copied to the output folder, then file is added to [resourceDir] it's need to be added here also // Static files that will be copied to the output folder, then file is added to [resourceDir] it's need to be added here also
...@@ -196,14 +194,6 @@ trait ReportBuilder extends ToolCommand { ...@@ -196,14 +194,6 @@ trait ReportBuilder extends ToolCommand {
createDirs = true) createDirs = true)
) )
logger.info("Parsing summary")
setSummary = SummaryDb.openSqliteSummary(cmdArgs.summaryDbFile)
setRunId = cmdArgs.runId
setSampleCache = Await.result(summary.getSamples(runId = Some(runId)), Duration.Inf).map(r => r.name -> r.id).toMap
setLibraryCache = Await.result(summary.getLibraries(runId = Some(runId)), Duration.Inf).map(r => (setSampleCache.find(_._2 == r.sampleId).get._1, r.name) -> r.id).toMap
setPipelineCache = Await.result(summary.getPipelines(runId = Some(runId)), Duration.Inf).map(r => r.name -> r.id).toMap
setModuleCache = Await.result(summary.getModules(runId = Some(runId)), Duration.Inf).map(r => r.name -> r.id).toMap
total = ReportBuilder.countPages(indexPage) total = ReportBuilder.countPages(indexPage)
logger.info(total + " pages to be generated") logger.info(total + " pages to be generated")
......
package nl.lumc.sasc.biopet.utils.implicits
/**
* Created by pjvanthof on 20/02/2017.
*/
object Either {
implicit def optionEitherLeft[T](x: Option[Either[T,_]]): Option[Option[T]] = {
x match {
case Some(i:Either[T, _]) if i.isLeft => Some(i.left.toOption)
case _ => None
}
}
implicit def optionEitherRight[T](x: Option[Either[_,T]]): Option[Option[T]] = {
x match {
case Some(i:Either[_,T]) if i.isRight => Some(i.right.toOption)
case _ => None
}
}
implicit def eitherLeft[T](x: Either[T,_]): Option[T] = {
x match {
case Left(x) => Some(x)
case _ => None
}
}
implicit def eitherRight[T](x: Either[_,T]): Option[T] = {
x match {
case Right(x) => Some(x)
case _ => None
}
}
implicit def left[T](x:T): Left[T, _] = Left(x)
implicit def right[T](x:T): Right[_, T] = Right(x)
implicit def left[T](x:Option[T]): Option[Left[T, _]] = x.map(Left(_))
implicit def right[T](x:Option[T]): Option[Right[_, T]] = x.map(Right(_))
}
...@@ -23,9 +23,9 @@ class SummaryDbTest extends TestNGSuite with Matchers { ...@@ -23,9 +23,9 @@ class SummaryDbTest extends TestNGSuite with Matchers {
Await.result(db.createOrUpdateSetting(0, 0, None, None, None, """{"content": "test" }"""), Duration.Inf) Await.result(db.createOrUpdateSetting(0, 0, None, None, None, """{"content": "test" }"""), Duration.Inf)
val bla = Await.result(db.getSettings(Some(0)), Duration.Inf) val bla = Await.result(db.getSettings(Some(0)), Duration.Inf)
Await.result(db.getSetting(0, 0, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test")) Await.result(db.getSetting(0, Left(0), None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test"))
Await.result(db.createOrUpdateSetting(0, 0, None, None, None, """{"content": "test2" }"""), Duration.Inf) Await.result(db.createOrUpdateSetting(0, 0, None, None, None, """{"content": "test2" }"""), Duration.Inf)
Await.result(db.getSetting(0, 0, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test2")) Await.result(db.getSetting(0, Left(0), None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test2"))
db.close() db.close()
} }
...@@ -37,9 +37,9 @@ class SummaryDbTest extends TestNGSuite with Matchers { ...@@ -37,9 +37,9 @@ class SummaryDbTest extends TestNGSuite with Matchers {
db.createTables() db.createTables()
Await.result(db.createOrUpdateStat(0, 0, None, None, None, """{"content": "test" }"""), Duration.Inf) Await.result(db.createOrUpdateStat(0, 0, None, None, None, """{"content": "test" }"""), Duration.Inf)
Await.result(db.getStat(0, 0, None, None, None), Duration.Inf) shouldBe Some(Map("content" -> "test"))