Skip to content

Commit

Permalink
fix(sql): Populating lastModified field for pipelines when loading ob…
Browse files Browse the repository at this point in the history
…jects. (#1220) (#1224)

* fix(cache): Fix caching all pipelines during sync loop.

* fix(cache): Fix caching all pipelines drring sync loop.

(cherry picked from commit 8daf680)

Co-authored-by: DanielaS12 <111055962+DanielaS12@users.noreply.github.com>
  • Loading branch information
mergify[bot] and DanielaS12 committed Mar 22, 2023
1 parent 0ff677e commit efff3fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ class SqlStorageService(
ctx
.select(
field("body", String::class.java),
field("created_at", Long::class.java)
field("created_at", Long::class.java),
field("last_modified_at", Long::class.java)
)
.from(definitionsByType[objectType]!!.tableName)
.where(
Expand All @@ -145,6 +146,8 @@ class SqlStorageService(
objectType.clazz as Class<T>
).apply {
this.createdAt = it.getValue(field("created_at", Long::class.java))

this.lastModified = it.getValue(field("last_modified_at", Long::class.java))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,28 @@ internal object SqlStorageServiceTests : JUnit5Minutests {
}
}

var lastModifiedMs : Long = 100
test("bulk load pipelines") {
val objectKeys = mutableSetOf<String>()
val lastModifiedList = mutableSetOf<Long>()
(1..10).forEach {
val objectKey = "id-pipeline00$it"
objectKeys.add(objectKey)
lastModifiedList.add(lastModifiedMs);

sqlStorageService.storeObject(
ObjectType.PIPELINE,
objectKey,
Pipeline().apply {
this.setId(objectKey)
this.setName("pipeline00$it")
this.setLastModified(100)
this.setLastModified(lastModifiedMs)

this.setApplication("application001")
}
)

lastModifiedMs+=(100..1000).random()
}

val pipelines = sqlStorageService.loadObjects<Pipeline>(
Expand All @@ -203,6 +208,9 @@ internal object SqlStorageServiceTests : JUnit5Minutests {
expectThat(
pipelines.map { it.id }.toSet()
).isEqualTo(objectKeys)
expectThat(
pipelines.map { it.lastModified }.toSet()
).isEqualTo(lastModifiedList)
}
}

Expand Down

0 comments on commit efff3fb

Please sign in to comment.