• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / atala-prism-building-blocks / 8898614027

30 Apr 2024 04:48PM UTC coverage: 49.277% (-0.3%) from 49.553%
8898614027

Pull #993

FabioPinheiro
ci: fix scala-steward after moving repo to hyperledger

Signed-off-by: FabioPinheiro <fabiomgpinheiro@gmail.com>

Update logback-classic to 1.4.14 in main

Update testcontainers-scala-postgresql to 0.41.3 in main

Update sbt-buildinfo to 0.12.0 in main

Update jwt-circe to 9.4.6 in main

Update munit-zio to 0.2.0 in main

Update sbt-native-packager to 1.9.16 in main

Update sbt-release to 1.4.0 in main

Update json-schema-validator to 1.3.3 in main

Update zio-json to 3.8.16 in main

Update tapir-http4s-server-zio to 1.10.5 in main

Update sbt-protoc to 1.0.7 in main

Update compilerplugin to 0.11.15 in main

Update typesafe:config to 1.4.3 in main

Update monocle-core to 3.2.0 in main

Update zio to 2.0.22 in main

Update zio-http to 3.0.0-RC6 in main

Update zio-interop-cats to 23.1.0.2 in main

Update zio-json to 0.6.2 in main

Update zio-logging to 2.1.17 in main

Update zio-metrics-connectors-micrometer to 2.3.1 in main

Update zio-mock to 1.0.0-RC12 in main

Update zio-prelude to 1.0.0-RC24 in main

Update circe-core to 0.14.7 in main

Update quill-doobie to 4.8.3 in main

Update micrometer-core to 1.11.11 in main

Update circe-json-schema to 0.4.1 in main

Update bcpkix-jdk15on to 1.78.1 in main

Update bcprov-jdk15on to 1.78.1 in main

Update didcomm to 0.3.2 in main

Update flyway-core to 9.22.3 in main

Update http4s-blaze-server to 0.23.16 in main

Update keycloak-authz-client to 24.0.3 in main

Update postgresql to 42.2.29 in main

Update sbt to 1.9.9 in main

Update munit to 1.0.0-RC1 in main

Update sbt-scalafmt to 2.5.2 in main

Update scalafmt-core to 3.7.17 in main

Reformat with scalafmt 3.7.17

Executed command: scalafmt --non-interactive

Add 'Reformat with scalafmt 3.7.17' to .git-blame-ignore-revs

Update scalatest to 3.2.18 in main

Update mockito-4-11 to 3.2.18.0 in main

Update sbt-coveralls to 1.3.11 in main

Update sbt-scoverage to 2.0.11 in main

Update slf4j-api to 2.0.13 in main

Update doobie-hikari to 1.0.0-RC5 in main
... (continued)
Pull Request #993: ci: fix scala-steward after moving repo to hyperledger

7 of 29 new or added lines in 3 files covered. (24.14%)

255 existing lines in 77 files now uncovered.

7296 of 14806 relevant lines covered (49.28%)

0.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.95
/pollux/sql-doobie/src/main/scala/org/hyperledger/identus/pollux/sql/model/db/CredentialSchema.scala
1
package org.hyperledger.identus.pollux.sql.model.db
2

3
import io.getquill.*
4
import io.getquill.context.json.PostgresJsonExtensions
5
import io.getquill.doobie.DoobieContext
6
import io.getquill.idiom.*
7
import org.hyperledger.identus.pollux.core.model.schema.Schema
8
import org.hyperledger.identus.shared.models.WalletId
9

10
import java.time.OffsetDateTime
11
import java.time.temporal.ChronoUnit
12
import java.util.UUID
13

14
case class CredentialSchema(
15
    guid: UUID,
16
    id: UUID,
17
    name: String,
18
    version: String,
19
    author: String,
20
    authored: OffsetDateTime,
21
    tags: Seq[String],
22
    description: String,
23
    `type`: String,
24
    schema: JsonValue[Schema],
25
    walletId: WalletId
26
) {
27
  lazy val uniqueConstraintKey = author + name + version
1✔
28

29
  def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): CredentialSchema =
1✔
30
    copy(authored = authored.truncatedTo(unit))
1✔
31

32
}
33

34
object CredentialSchema {
35
  def fromModel(
1✔
36
      m: org.hyperledger.identus.pollux.core.model.schema.CredentialSchema,
37
      walletId: WalletId
38
  ): CredentialSchema =
39
    CredentialSchema(
40
      guid = m.guid,
41
      id = m.id,
42
      name = m.name,
43
      version = m.version,
44
      author = m.author,
45
      authored = m.authored,
46
      tags = m.tags,
47
      description = m.description,
48
      `type` = m.`type`,
49
      schema = JsonValue(m.schema),
50
      walletId = walletId
51
    )
52

53
  def toModel(
1✔
54
      db: CredentialSchema
55
  ): org.hyperledger.identus.pollux.core.model.schema.CredentialSchema = {
56
    org.hyperledger.identus.pollux.core.model.schema.CredentialSchema(
57
      guid = db.guid,
58
      id = db.id,
59
      name = db.name,
60
      version = db.version,
61
      author = db.author,
62
      authored = db.authored,
63
      tags = db.tags,
64
      description = db.description,
65
      `type` = db.`type`,
66
      schema = db.schema.value
67
    )
68
  }
69
}
70

71
object CredentialSchemaSql extends DoobieContext.Postgres(SnakeCase) with PostgresJsonExtensions {
72
  def insert(schema: CredentialSchema) = run {
1✔
73
    quote(
74
      query[CredentialSchema]
75
        .insertValue(lift(schema))
76
    ).returning(cs => cs)
77
  }
78

79
  def findByGUID(guid: UUID) = run {
1✔
80
    quote(query[CredentialSchema].filter(_.guid == lift(guid)).take(1))
81
  }
82

83
  def findByID(id: UUID) = run {
×
84
    quote(query[CredentialSchema].filter(_.id == lift(id)))
85
  }
86

87
  def getAllVersions(id: UUID, author: String) = run {
1✔
88
    quote(
89
      query[CredentialSchema]
90
        .filter(_.id == lift(id))
91
        .filter(_.author == lift(author))
92
        .sortBy(_.version)(ord = Ord.asc)
93
        .map(_.version)
94
    )
95
  }
96

97
  def update(schema: CredentialSchema) = run {
1✔
98
    quote {
99
      query[CredentialSchema]
100
        .filter(_.guid == lift(schema.guid))
101
        .updateValue(lift(schema))
102
        .returning(s => s)
103
    }
104
  }
105

106
  def delete(guid: UUID) = run {
1✔
107
    quote {
108
      query[CredentialSchema]
109
        .filter(_.guid == lift(guid))
110
        .delete
111
        .returning(cs => cs)
112
    }
113
  }
114

115
  def deleteAll = run {
1✔
116
    quote {
117
      query[CredentialSchema].delete
118
    }
119
  }
120

121
  def totalCount = run {
1✔
122
    quote {
123
      query[CredentialSchema].size
124
    }
125
  }
126

127
  def lookupCount(
1✔
128
      idOpt: Option[UUID] = None,
1✔
129
      authorOpt: Option[String] = None,
1✔
130
      nameOpt: Option[String] = None,
1✔
131
      versionOpt: Option[String] = None,
1✔
132
      tagOpt: Option[String] = None
1✔
133
  ) = run {
1✔
134
    val q =
135
      idOpt.fold(quote(query[CredentialSchema]))(id => quote(query[CredentialSchema].filter(cs => cs.id == lift(id))))
1✔
136

137
    q.dynamic
1✔
138
      .filterOpt(authorOpt)((cs, author) => quote(cs.author.like(author)))
139
      .filterOpt(nameOpt)((cs, name) => quote(cs.name.like(name)))
140
      .filterOpt(versionOpt)((cs, version) => quote(cs.version.like(version)))
141
      .filter(cs =>
1✔
142
        tagOpt
143
          .fold(quote(true))(tag => quote(cs.tags.contains(lift(tag))))
1✔
144
      )
145
      .size
1✔
146
  }
147

148
  def lookup(
1✔
149
      idOpt: Option[UUID] = None,
1✔
150
      authorOpt: Option[String] = None,
×
151
      nameOpt: Option[String] = None,
×
152
      versionOpt: Option[String] = None,
×
153
      tagOpt: Option[String] = None,
×
154
      offset: Int = 0,
×
155
      limit: Int = 1000
×
UNCOV
156
  ) = run {
×
157
    val q =
158
      idOpt.fold(quote(query[CredentialSchema]))(id => quote(query[CredentialSchema].filter(cs => cs.id == lift(id))))
1✔
159

160
    q.dynamic
1✔
161
      .filterOpt(authorOpt)((cs, author) => quote(cs.author.like(author)))
162
      .filterOpt(nameOpt)((cs, name) => quote(cs.name.like(name)))
163
      .filterOpt(versionOpt)((cs, version) => quote(cs.version.like(version)))
164
      .filter(cs =>
1✔
165
        tagOpt
166
          .fold(quote(true))(tag => quote(cs.tags.contains(lift(tag))))
1✔
167
      )
168
      .sortBy(cs => cs.id)
169
      .drop(offset)
170
      .take(limit)
171
  }
172
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc