package com.nisemoe.nise.database

import com.nisemoe.generated.tables.references.BEATMAPS
import com.nisemoe.generated.tables.references.SCORES
import com.nisemoe.generated.tables.references.SCORES_SIMILARITY
import com.nisemoe.generated.tables.references.USERS
import com.nisemoe.nise.Statistics
import org.jooq.DSLContext
import org.springframework.stereotype.Service

@Service
class StatisticsService(private val dslContext: DSLContext) {

    fun getStatistics(): Statistics {
        return Statistics(
            dslContext.fetchCount(BEATMAPS),
            dslContext.fetchCount(USERS),
            dslContext.fetchCount(SCORES),
            dslContext.fetchCount(SCORES, SCORES.REPLAY.isNotNull),
            dslContext.fetchCount(SCORES_SIMILARITY)
        )
    }

}