Skip to content

Commit

Permalink
- enable demo mode
Browse files Browse the repository at this point in the history
- problems are loaded in lazy way
  • Loading branch information
spolnik committed Aug 7, 2018
1 parent 826f7ae commit aa01ca2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/kotlin/com/jalgoarena/data/JsonProblemsRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArrayList

@Repository
open class JsonProblemsRepository : ProblemsRepository {
open class JsonProblemsRepository(
@Value("\${jalgoarena.problems.source:problems.json}")
private val jalgoarenaProblemsSource: String = "problems.json"
) : ProblemsRepository {

private val problems: CopyOnWriteArrayList<Problem> = CopyOnWriteArrayList()
private val problemsById: ConcurrentHashMap<String, Problem> = ConcurrentHashMap()

@Value("\${jalgoarena.problems.source}")
private lateinit var jalgoarenaProblemsSource: String

override fun find(id: String): Problem? {
if (problemsById.isEmpty()) {
init(jalgoarenaProblemsSource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.jalgoarena.data
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Test
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
class JsonProblemsRepositoryTest {

private lateinit var problemsRepository: ProblemsRepository
Expand Down

0 comments on commit aa01ca2

Please sign in to comment.