Skip to content

Commit

Permalink
Address code review comments, thanks @S11001001
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-da committed Jan 8, 2020
1 parent d050b2f commit a6dc267
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
1 change: 0 additions & 1 deletion ledger-service/db-backend/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ da_scala_library(
"@maven//:org_scalaz_scalaz_core_2_12",
"@maven//:org_tpolecat_doobie_core_2_12",
"@maven//:org_tpolecat_doobie_free_2_12",
"@maven//:org_tpolecat_doobie_postgres_2_12",
"@maven//:org_typelevel_cats_core_2_12",
"@maven//:org_typelevel_cats_effect_2_12",
"@maven//:org_typelevel_cats_free_2_12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ object Queries {
hd ++ go(0, tl.size)
}

@silent // gvs is demonstrably used; try taking it out
private[http] def selectContracts(party: String, tpid: SurrogateTpId, predicate: Fragment)(
implicit log: LogHandler): Query0[DBContract[Unit, JsValue, JsValue, Vector[String]]] = {
import doobie.postgres.implicits._

implicit log: LogHandler,
gvs: Get[Vector[String]]): Query0[DBContract[Unit, JsValue, JsValue, Vector[String]]] = {
val q = sql"""SELECT contract_id, key, payload, signatories, observers, agreement_text
FROM contract AS c
WHERE (signatories @> ARRAY[$party::text] OR observers @> ARRAY[$party::text])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ private class ContractsFetch(
_ = logger.debug(s"contractsFromOffsetIo($jwt, $party, $templateId, $ob0): $offset1")
} yield offset1

@SuppressWarnings(Array("org.wartremover.warts.Any"))
private def prepareCreatedEventStorage(
ce: lav1.event.CreatedEvent): Exception \/ PreInsertContract =
ce: lav1.event.CreatedEvent): Exception \/ PreInsertContract = {
import scalaz.syntax.traverse._
import scalaz.std.option._
for {
ac <- domain.ActiveContract fromLedgerApi ce leftMap (de =>
new IllegalArgumentException(s"contract ${ce.contractId}: ${de.shows}"))
lfKey <- ac.key.cata(
k => apiValueToLfValue(k) map (Some(_)) leftMap (_.cause),
\/-(None)
)
lfKey <- ac.key.traverse(apiValueToLfValue).leftMap(_.cause)
lfArg <- apiValueToLfValue(ac.payload) leftMap (_.cause)
} yield
DBContract(
Expand All @@ -126,6 +126,7 @@ private class ContractsFetch(
observers = ac.observers,
agreementText = ac.agreementText
)
}

@SuppressWarnings(Array("org.wartremover.warts.Any"))
private def jsonifyInsertDeleteStep(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ object ContractDao {
party: domain.Party,
templateId: domain.TemplateId.RequiredPkg,
predicate: doobie.Fragment)(
implicit log: LogHandler): ConnectionIO[Vector[domain.ActiveContract[JsValue]]] =
implicit log: LogHandler): ConnectionIO[Vector[domain.ActiveContract[JsValue]]] = {
import doobie.postgres.implicits._
for {
tpId <- Queries.surrogateTemplateId(
templateId.packageId,
Expand All @@ -81,6 +82,7 @@ object ContractDao {
dbContracts <- Queries.selectContracts(party.unwrap, tpId, predicate).to[Vector]
domainContracts = dbContracts.map(toDomain(templateId))
} yield domainContracts
}

private def toDomain(templateId: domain.TemplateId.RequiredPkg)(
a: Queries.DBContract[Unit, JsValue, JsValue, Vector[String]])
Expand Down

0 comments on commit a6dc267

Please sign in to comment.