forked from github/szkolny
[DB/Grades] Fix DataRemoveModel deleting models instead of marking as don't keep.
This commit is contained in:
parent
cadd1a3dbd
commit
48873caecc
@ -38,12 +38,12 @@ open class DataRemoveModel {
|
|||||||
|
|
||||||
fun commit(profileId: Int, dao: GradeDao) {
|
fun commit(profileId: Int, dao: GradeDao) {
|
||||||
if (all) {
|
if (all) {
|
||||||
if (type != null) dao.clearWithType(profileId, type)
|
if (type != null) dao.dontKeepWithType(profileId, type)
|
||||||
else dao.clear(profileId)
|
else dao.clear(profileId)
|
||||||
}
|
}
|
||||||
semester?.let {
|
semester?.let {
|
||||||
if (type != null) dao.clearForSemesterWithType(profileId, it, type)
|
if (type != null) dao.dontKeepForSemesterWithType(profileId, it, type)
|
||||||
else dao.clearForSemester(profileId, it)
|
else dao.dontKeepForSemester(profileId, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,14 +82,14 @@ abstract class GradeDao : BaseDao<Grade, GradeFull> {
|
|||||||
fun getByIdNow(profileId: Int, id: Long) =
|
fun getByIdNow(profileId: Int, id: Long) =
|
||||||
getOneNow("$QUERY WHERE grades.profileId = $profileId AND gradeId = $id")
|
getOneNow("$QUERY WHERE grades.profileId = $profileId AND gradeId = $id")
|
||||||
|
|
||||||
@Query("DELETE FROM grades WHERE profileId = :profileId AND gradeType = :type")
|
@Query("UPDATE grades SET keep = 0 WHERE profileId = :profileId AND gradeType = :type")
|
||||||
abstract fun clearWithType(profileId: Int, type: Int)
|
abstract fun dontKeepWithType(profileId: Int, type: Int)
|
||||||
|
|
||||||
@Query("DELETE FROM grades WHERE profileId = :profileId AND gradeSemester = :semester")
|
@Query("UPDATE grades SET keep = 0 WHERE profileId = :profileId AND gradeSemester = :semester")
|
||||||
abstract fun clearForSemester(profileId: Int, semester: Int)
|
abstract fun dontKeepForSemester(profileId: Int, semester: Int)
|
||||||
|
|
||||||
@Query("DELETE FROM grades WHERE profileId = :profileId AND gradeSemester = :semester AND gradeType = :type")
|
@Query("UPDATE grades SET keep = 0 WHERE profileId = :profileId AND gradeSemester = :semester AND gradeType = :type")
|
||||||
abstract fun clearForSemesterWithType(profileId: Int, semester: Int, type: Int)
|
abstract fun dontKeepForSemesterWithType(profileId: Int, semester: Int, type: Int)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user