Skip to content

Commit

Permalink
Fix #1153 无法修改评分
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Nov 9, 2024
1 parent 6237b16 commit 9a3747a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,17 @@ interface SubjectCollectionDao {
@Query("""SELECT lastUpdated FROM subject_collection ORDER BY lastUpdated DESC LIMIT 1""")
suspend fun lastUpdated(): Long

@Query("""UPDATE subject_collection SET self_rating_score = :score, self_rating_comment = :comment, self_rating_tags = :tags, self_rating_isPrivate = :private WHERE subjectId = :subjectId""")
@Query(
"""
UPDATE subject_collection
SET
self_rating_score = COALESCE(:score, self_rating_score),
self_rating_comment = COALESCE(:comment, self_rating_comment),
self_rating_tags = COALESCE(:tags, self_rating_tags),
self_rating_isPrivate = COALESCE(:private, self_rating_isPrivate)
WHERE subjectId = :subjectId
""",
)
suspend fun updateRating(subjectId: Int, score: Int?, comment: String?, tags: List<String>?, private: Boolean?)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,15 @@ sealed interface SubjectCollectionRepository : Repository {
types: List<UnifiedCollectionType>? = null, // null for all
): Flow<List<SubjectCollectionInfo>>

/**
* @param score 0 to remove rating
* @param comment set empty to remove
* @param tags set empty to remove
*/
suspend fun updateRating(
subjectId: Int,
score: Int? = null, // 0 to remove rating
comment: String? = null, // set empty to remove
score: Int? = null,
comment: String? = null,
tags: List<String>? = null,
isPrivate: Boolean? = null,
)
Expand Down

0 comments on commit 9a3747a

Please sign in to comment.