| | |
| | | import androidx.annotation.WorkerThread |
| | | import com.example.firstapp.database.dao.CodeDao |
| | | import com.example.firstapp.database.entity.Code |
| | | import kotlinx.coroutines.Dispatchers |
| | | import kotlinx.coroutines.flow.Flow |
| | | import kotlinx.coroutines.withContext |
| | | |
| | | |
| | | class CodeRepository(private val codeDao: CodeDao) { |
| | |
| | | } |
| | | } |
| | | |
| | | fun getCourierStats(date: Long) = codeDao.getCourierStatsByWeek(date) |
| | | fun getCourierStats(date: Long, dateType: String) = when(dateType) { |
| | | "WEEK" -> codeDao.getCourierStatsByWeek(date) |
| | | "MONTH" -> codeDao.getCourierStatsByMonth(date) |
| | | "YEAR" -> codeDao.getCourierStatsByYear(date) |
| | | else -> codeDao.getCourierStatsByWeek(date) |
| | | } |
| | | |
| | | fun getDailyStats(date: Long) = codeDao.getDailyStatsByWeek(date) |
| | | // fun getStats(date: Long, dateType: String) = when(dateType) { |
| | | // "WEEK" -> codeDao.getDailyStatsByWeek(date) |
| | | // "MONTH" -> codeDao.getMonthlyStats(date) |
| | | // "YEAR" -> codeDao.getYearlyStats(date) |
| | | // else -> codeDao.getDailyStatsByWeek(date) |
| | | // } |
| | | |
| | | |
| | | @WorkerThread |
| | |
| | | return codeDao.getNewPackagesByDay(date) |
| | | } |
| | | |
| | | fun getYearlyHeatmap(date: Long) = codeDao.getYearlyHeatmap(date) |
| | | |
| | | fun getWeeklyStats(date: Long, weekCount: Int) = codeDao.getWeeklyStats(date, weekCount) |
| | | |
| | | fun getMonthlyStats(date: Long) = codeDao.getMonthlyStats(date) |
| | | |
| | | |
| | | fun getYearlyStats(date: Long) = codeDao.getYearlyStats(date) |
| | | |
| | | fun getYearMonthlyStats(date: Long) = codeDao.getYearMonthlyStats(date) |
| | | |
| | | } |