package com.nisemoe.nise.controller

import com.nisemoe.nise.Statistics
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 StatisticsController (
    private val globalCache: GlobalCache
) {

    @GetMapping("stats")
    fun getStatistics(): ResponseEntity<Statistics> {
        val statistics = this.globalCache.statistics
            ?: return ResponseEntity.status(503).build()

        return ResponseEntity.ok(statistics)
    }

}