package com.nisemoe.nise.controller

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

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

    @GetMapping("suspicious-scores", produces = [MediaType.APPLICATION_JSON_VALUE])
    fun getSuspiciousScores(): ResponseEntity<List<SuspiciousScoreEntry>> {
        val scores = this.globalCache.suspiciousScores
            ?: return ResponseEntity.status(503).build()

        return ResponseEntity.ok(scores)
    }


}