Skip to content

Commit

Permalink
🗃️ Revert "Migrate Case.hasDocuments on startup"
Browse files Browse the repository at this point in the history
This reverts commit 2aed6b1.
  • Loading branch information
obecker committed Feb 18, 2024
1 parent 2aed6b1 commit 8a78092
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
13 changes: 0 additions & 13 deletions backend/src/main/kotlin/de/obqo/causalist/app/Main.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package de.obqo.causalist.app

import de.obqo.causalist.CaseDocumentRepository
import de.obqo.causalist.CaseRepository
import de.obqo.causalist.Config
import de.obqo.causalist.CryptoUtils
import de.obqo.causalist.CryptoUtils.decrypt
Expand Down Expand Up @@ -132,8 +130,6 @@ private fun buildApi(environment: Environment): HttpHandler {
token.encrypt(key).decrypt(key)
}

migrateCaseHasDocuments(caseDocumentRepository, caseRepository)

return object : HttpHandler, Resource {

init {
Expand All @@ -151,12 +147,3 @@ private fun buildApi(environment: Environment): HttpHandler {
}
}
}

fun migrateCaseHasDocuments(caseDocumentRepository: CaseDocumentRepository, caseRepository: CaseRepository) {
caseDocumentRepository.findAll().toList()
.groupBy { case -> case.ownerId to case.refId }
.keys
.mapNotNull { (ownerId, refId) -> caseRepository.get(ownerId, refId) }
.map { it.copy(hasDocuments = true) }
.let { caseRepository.save(it) }
}
8 changes: 3 additions & 5 deletions infrastructure/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ resource "aws_lambda_function" "backend" {
source_code_hash = data.local_file.lambda_handler_lib.content_base64sha256
publish = true

# snap_start {
# apply_on = "PublishedVersions"
# }
snap_start {
apply_on = "PublishedVersions"
}

environment {
variables = {
Expand Down Expand Up @@ -65,8 +65,6 @@ resource "aws_iam_policy" "dynamodb" {
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:BatchWriteItem"
]
Resource = [
"${aws_dynamodb_table.db_users.arn}",
Expand Down

0 comments on commit 8a78092

Please sign in to comment.