package com.nisemoe.nise.controller

import com.nisemoe.nise.SimilarReplayEntry
import com.nisemoe.nise.scheduler.GlobalCache
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class StolenReplaysController(
    private val globalCache: GlobalCache
) {

    @GetMapping("similar-replays")
    fun getStolenReplays(): ResponseEntity<List<SimilarReplayEntry>> {
        val stolenReplays = this.globalCache.similarReplays
            ?: return ResponseEntity.status(503).build()

        return ResponseEntity.ok(stolenReplays)
    }

}