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

TOR-xxxx: Korjaa kuka katsoi tietojani -näkymä #3257

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object AuditLogMockData extends Logging {
.map{ case (data, index) => Map(
"studentOid" -> AttributeValue.builder.s(data.studentOid).build(),
"time" -> AttributeValue.builder.s(data.time).build(),
"organizationOid" -> AttributeValue.builder.ss(data.organizationOid.asJava).build(),
"organizationOid" -> AttributeValue.builder.l(data.organizationOid.map(o => AttributeValue.builder.s(o).build()).asJava).build(),
"id" -> AttributeValue.builder.s(index.toString).build(),
"raw" -> AttributeValue.builder.s(data.raw).build()
).asJava}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import fi.oph.koski.json.JsonSerializer
import fi.oph.koski.log.Logging
import fi.oph.koski.schema.LocalizedString
import fi.oph.koski.omaopintopolkuloki.AuditLogDynamoDB.AuditLogTableName
import fi.oph.scalaschema.Serializer.format
import org.json4s.{Extraction, JValue}
import org.json4s.jackson.JsonMethods.compact
import software.amazon.awssdk.services.dynamodb.DynamoDbClient
import software.amazon.awssdk.services.dynamodb.model.QueryResponse
import software.amazon.awssdk.services.dynamodb.model.{AttributeValue, QueryRequest}

import scala.collection.JavaConverters._
Expand Down Expand Up @@ -52,7 +47,10 @@ class AuditLogService(app: KoskiApplication) extends Logging {
}
private def convertToAuditLogRow(item: util.Map[String, AttributeValue]): AuditlogRow = {
val organizationOid = item.asScala.view.collectFirst {
case ("organizationOid", value) if value.ss() != null => value.ss().asScala.toList
case ("organizationOid", value) if value.l() != null =>
value.l().asScala.toList.collect {
case v if v.s() != null => v.s()
}
}.getOrElse(List.empty[String])

val raw = item.asScala.view.collectFirst {
Expand All @@ -70,7 +68,7 @@ class AuditLogService(app: KoskiApplication) extends Logging {
val timestampsGroupedByListOfOidsAndServiceName = queryResults.map(item => {
val parsedRow = convertToAuditLogRow(item)
val parsedRaw = JsonSerializer.parse[AuditlogRaw](parsedRow.raw, ignoreExtras = true)
val organisaatioOidit = parsedRow.organizationOid
val organisaatioOidit = parsedRow.organizationOid.sorted
val timestampString = parsedRow.time
val serviceName = parsedRaw.serviceName
(organisaatioOidit, serviceName, timestampString)
Expand Down
Loading