Skip to content

Commit e679fa4

Browse files
icreatedicreated
authored andcommitted
Creation & refresh dates
1 parent dd766c5 commit e679fa4

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

dataset/src/main/kotlin/com/cosmotech/dataset/service/DatasetServiceImpl.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import com.redislabs.redisgraph.graph_entities.Edge
6868
import com.redislabs.redisgraph.graph_entities.Node
6969
import java.io.InputStream
7070
import java.nio.charset.StandardCharsets
71+
import java.time.Instant
7172
import kotlinx.coroutines.GlobalScope
7273
import kotlinx.coroutines.launch
7374
import org.apache.commons.compress.archivers.ArchiveStreamFactory
@@ -174,6 +175,7 @@ class DatasetServiceImpl(
174175
twingraphId = twingraphId,
175176
sourceType = dataset.sourceType ?: DatasetSourceType.None,
176177
main = dataset.main ?: true,
178+
creationDate = Instant.now().toEpochMilli(),
177179
status = Dataset.Status.DRAFT,
178180
ownerId = getCurrentAuthenticatedUserName(csmPlatformProperties),
179181
organizationId = organizationId)
@@ -222,6 +224,7 @@ class DatasetServiceImpl(
222224
twingraphId = subTwingraphId,
223225
queries = subDatasetGraphQuery.queries,
224226
main = subDatasetGraphQuery.main ?: dataset.main,
227+
creationDate = Instant.now().toEpochMilli(),
225228
parentId = dataset.id,
226229
status = Dataset.Status.READY,
227230
connector =
@@ -350,7 +353,11 @@ class DatasetServiceImpl(
350353
dataset.status?.takeUnless { it == Dataset.Status.PENDING }
351354
?: throw CsmClientException("Dataset in use, cannot update. Retry later")
352355

353-
datasetRepository.save(dataset.apply { status = Dataset.Status.PENDING })
356+
datasetRepository.save(
357+
dataset.apply {
358+
refreshDate = Instant.now().toEpochMilli()
359+
status = Dataset.Status.PENDING
360+
})
354361

355362
val dataSourceLocation =
356363
if (dataset.sourceType == DatasetSourceType.Twincache) {

dataset/src/main/openapi/dataset.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,16 @@ components:
12341234
main:
12351235
type: boolean
12361236
description: is this the main dataset
1237+
creationDate:
1238+
type: integer
1239+
format: int64
1240+
readOnly: true
1241+
description: the Dataset creation date
1242+
refreshDate:
1243+
type: integer
1244+
format: int64
1245+
readOnly: true
1246+
description: the last time a refresh was done
12371247
sourceType:
12381248
$ref: '#/components/schemas/DatasetSourceType'
12391249
source:

doc/Models/Dataset.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Name | Type | Description | Notes
1111
**parentId** | **String** | the Dataset id which is the parent of this Dataset | [optional] [default to null]
1212
**twingraphId** | **String** | the twin graph id | [optional] [default to null]
1313
**main** | **Boolean** | is this the main dataset | [optional] [default to null]
14+
**creationDate** | **Long** | the Dataset creation date | [optional] [default to null]
15+
**refreshDate** | **Long** | the last time a refresh was done | [optional] [default to null]
1416
**sourceType** | [**DatasetSourceType**](DatasetSourceType.md) | | [optional] [default to null]
1517
**source** | [**SourceInfo**](SourceInfo.md) | | [optional] [default to null]
1618
**status** | **String** | the Dataset status | [optional] [default to null]

openapi/plantuml/schemas.plantuml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ entity Dataset {
5757
parentId: String
5858
twingraphId: String
5959
main: Boolean
60+
creationDate: Long
61+
refreshDate: Long
6062
sourceType: DatasetSourceType
6163
source: SourceInfo
6264
status: String

0 commit comments

Comments
 (0)