| | |
| | | import androidx.lifecycle.AndroidViewModel |
| | | import androidx.lifecycle.asLiveData |
| | | import androidx.lifecycle.viewModelScope |
| | | import androidx.room.RewriteQueriesToDropUnusedColumns |
| | | import com.example.firstapp.AppDatabase |
| | | import com.example.firstapp.database.entity.Code |
| | | import com.example.firstapp.database.repository.CodeRepository |
| | |
| | | |
| | | fun getYearlyHeatmap(date: Long) = repository.getYearlyHeatmap(date).asLiveData() |
| | | |
| | | |
| | | fun getWeeklyStats(date: Long, weekCount: Int = 6) = |
| | | repository.getWeeklyStats(date, weekCount).asLiveData() |
| | | |
| | |
| | | fun insert(code: Code) = viewModelScope.launch { |
| | | repository.insert(code) |
| | | } |
| | | |
| | | fun getCurrentWeekStats(date: Long) = |
| | | repository.getCurrentWeekStats(date).asLiveData() |
| | | |
| | | fun getCurrentYearStats(date: Long) = |
| | | repository.getCurrentYearStats(date).asLiveData() |
| | | } |