[DB/Grades] Fix DataRemoveModel deleting models instead of marking as don't keep.

This commit is contained in:
Kacper Ziubryniewicz 2020-05-14 11:43:22 +02:00
parent cadd1a3dbd
commit 48873caecc
2 changed files with 9 additions and 9 deletions

View File

@ -38,12 +38,12 @@ open class DataRemoveModel {
fun commit(profileId: Int, dao: GradeDao) {
if (all) {
if (type != null) dao.clearWithType(profileId, type)
if (type != null) dao.dontKeepWithType(profileId, type)
else dao.clear(profileId)
}
semester?.let {
if (type != null) dao.clearForSemesterWithType(profileId, it, type)
else dao.clearForSemester(profileId, it)
if (type != null) dao.dontKeepForSemesterWithType(profileId, it, type)
else dao.dontKeepForSemester(profileId, it)
}
}
}

View File

@ -82,14 +82,14 @@ abstract class GradeDao : BaseDao<Grade, GradeFull> {
fun getByIdNow(profileId: Int, id: Long) =
getOneNow("$QUERY WHERE grades.profileId = $profileId AND gradeId = $id")
@Query("DELETE FROM grades WHERE profileId = :profileId AND gradeType = :type")
abstract fun clearWithType(profileId: Int, type: Int)
@Query("UPDATE grades SET keep = 0 WHERE profileId = :profileId AND gradeType = :type")
abstract fun dontKeepWithType(profileId: Int, type: Int)
@Query("DELETE FROM grades WHERE profileId = :profileId AND gradeSemester = :semester")
abstract fun clearForSemester(profileId: Int, semester: Int)
@Query("UPDATE grades SET keep = 0 WHERE profileId = :profileId AND gradeSemester = :semester")
abstract fun dontKeepForSemester(profileId: Int, semester: Int)
@Query("DELETE FROM grades WHERE profileId = :profileId AND gradeSemester = :semester AND gradeType = :type")
abstract fun clearForSemesterWithType(profileId: Int, semester: Int, type: Int)
@Query("UPDATE grades SET keep = 0 WHERE profileId = :profileId AND gradeSemester = :semester AND gradeType = :type")
abstract fun dontKeepForSemesterWithType(profileId: Int, semester: Int, type: Int)