Skip to content

Commit

Permalink
Korjaa kuka katsoi tietojani -näkymä;
Browse files Browse the repository at this point in the history
Lokaaleissa mockeissa, ja sen seurauksena myös koodissa, käytettiin auditlogitauluissa eri formaattia kuin tuotantoympäristöissä pyörivässä DynamoDB:ssä.

Lisätty myös sorttaus organisaatio-oideille, jotta pelkästään eri järjestyksessä olevat organisaatio-oidit ryhmitellään samaan lohkoon.
  • Loading branch information
AleksiAhtiainen committed Dec 20, 2024
1 parent 0f4b1eb commit 2275957
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
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

0 comments on commit 2275957

Please sign in to comment.