package com.isidroid.job_sender.domain.use_case

import com.isidroid.core.DiMock
import com.isidroid.job.constant.JobStatus
import com.isidroid.job.constant.SendJobStatus
import com.isidroid.job.constant.jobStatusName
import com.isidroid.job.constant.sendJobStatusName
import com.isidroid.job_sender.repository.JobSendRepository
import timber.log.Timber
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class SendPrintJobsUseCase @Inject constructor(
    private val repository: JobSendRepository,
    @DiMock private val debug: Boolean
) {
    suspend fun start() {
        repository.checkNotRenderedPrintJobs(repository.getJobList(JobStatus.IDLE))
        repository.readFilesAndSend(repository.getJobSenderList(SendJobStatus.RENDERED))
        repository.markJobUploaded(repository.getJobList(JobStatus.RENDER_UPLOAD))

        // let's check
        val printJobs = repository.getJobList(status = null)
        val pages = repository.getJobSenderList(status = null)

//        Timber.i("===> printJobs: count=${printJobs.size}, list=${printJobs.map { it.status.jobStatusName }}")
//        Timber.i("===> pages: count=${pages.size}, list=${pages.map { it.status.sendJobStatusName }}")
    }
}