Skip to content

Commit

Permalink
fix: Demo project creation
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar committed Dec 14, 2023
1 parent 7fd3f87 commit c9d3c3b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class QuickStartModelAssembler() : RepresentationModelAssemblerSupport<QuickStar
override fun toModel(entity: QuickStart): QuickStartModel {
return QuickStartModel(
finished = entity.finished,
completedSteps = entity.completedSteps,
completedSteps = entity.completedSteps.toMutableList(),
open = entity.open
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ class CurrentDateProvider(
private val applicationEventPublisher: ApplicationEventPublisher,
private val transactionManager: PlatformTransactionManager
) : Logging, DateTimeProvider {
private fun getServerTimeEntity(): ForcedServerDateTime? =
entityManager.createQuery(
"select st from ForcedServerDateTime st where st.id = 1",
ForcedServerDateTime::class.java
).resultList.singleOrNull()

var forcedDate: Date? = null
set(value) {
if (field != value) {
Expand Down Expand Up @@ -67,8 +61,7 @@ class CurrentDateProvider(
}

init {
val forcedServerDateTime: ForcedServerDateTime? = getServerTimeEntity()
forcedDate = forcedServerDateTime?.time
forcedDate = getForcedTime()
auditingHandler.setDateTimeProvider(this)
}

Expand All @@ -90,4 +83,16 @@ class CurrentDateProvider(
override fun getNow(): Optional<TemporalAccessor> {
return Optional.of(date.toInstant())
}

private fun getServerTimeEntity(): ForcedServerDateTime? =
entityManager.createQuery(
"select st from ForcedServerDateTime st where st.id = 1",
ForcedServerDateTime::class.java
).resultList.singleOrNull()

private fun getForcedTime(): Date? =
entityManager.createNativeQuery(
"select st from forced_server_date_time st where st.id = 1",
Date::class.java
).resultList.singleOrNull() as Date?
}
2 changes: 1 addition & 1 deletion backend/data/src/main/kotlin/io/tolgee/model/QuickStart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ data class QuickStart(

@Type(StringArrayType::class)
@Column(columnDefinition = "text[]")
var completedSteps: MutableList<String> = mutableListOf()
var completedSteps: Array<String> = arrayOf()
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class QuickStartService(
fun completeStep(userAccount: UserAccountDto, step: String): QuickStart? {
val quickStart = quickStartRepository.findByUserAccountId(userAccount.id)
if (quickStart?.completedSteps?.let { !it.contains(step) } == true) {
quickStart.completedSteps.add(step)
quickStart.completedSteps = quickStart.completedSteps.plus(step)
quickStartRepository.save(quickStart)
}
return quickStart
Expand Down

0 comments on commit c9d3c3b

Please sign in to comment.