Rev 1 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
package com.cesams.twogetskills.inconcert.dao;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Insert;
import androidx.room.Update;
import com.cesams.twogetskills.inconcert.entity.Progress;
import com.cesams.twogetskills.inconcert.room.ResultCount;
import com.cesams.twogetskills.inconcert.room.ResultTotalInt;
import java.util.List;
@Dao
public interface ProgressDao {
@Query("SELECT COUNT(*) AS count FROM tb_progress where topic_uuid = :topicUuid AND type = 's' AND completed = 1 AND user_uuid = :userUuid")
ResultCount getCountSlidesCompletedByTopicUuidAndUserUuid(String topicUuid, String userUuid);
@Query("SELECT COUNT(*) AS count FROM tb_progress where topic_uuid = :topicUuid AND type = 'c' AND completed = 1 AND user_uuid = :userUuid")
ResultCount getCountCapsulesCompletedByTopicUuidAndUserUuid(String topicUuid, String userUuid);
@Query("SELECT COUNT(*) AS count FROM tb_progress where topic_uuid = :topicUuid AND type = 'c' AND completed = 1 AND user_uuid = :userUuid AND returning_after_completed = 0")
ResultCount getCountCapsulesCompletedWithoutReturningByTopicUuidAndUserUuid(String topicUuid, String userUuid);
@Query("SELECT SUM(returning_after_completed) AS total FROM tb_progress where topic_uuid = :topicUuid AND user_uuid = :userUuid AND type = 'c' AND completed = 1 AND returning_after_completed > 0")
ResultTotalInt getCountCapsulesCompletedWithReturningByTopicUuidAndUserUuid(String topicUuid, String userUuid);
@Query("SELECT COUNT(*) AS count FROM tb_progress where capsule_uuid = :capsuleUuid AND user_uuid = :userUuid AND type = 's' AND completed = 1")
ResultCount getCountSlidesCompletedByCapsuleUuidAndUserUuid(String capsuleUuid, String userUuid);
@Query("SELECT SUM(returning_after_completed) AS total FROM tb_progress where topic_uuid = :topicUuid AND type = 'c' AND completed = 1 AND returning_after_completed > 0")
ResultTotalInt getCountCapsulesCompletedWithReturningByTopicUuid(String topicUuid);
@Query("SELECT COUNT(*) AS count FROM tb_progress where capsule_uuid = :capsuleUuid AND type = 's' AND completed = 1")
ResultCount getCountSlidesCompletedByCapsuleUuid(String capsuleUuid);
@Query("SELECT * FROM tb_progress WHERE topic_uuid = :topicUuid AND type = 't' LIMIT 1")
Progress selectByTopicUuid(String topicUuid);
@Query("SELECT * FROM tb_progress WHERE topic_uuid = :topicUuid AND user_uuid = :userUuid AND type = 't' LIMIT 1")
Progress selectByTopicUuidAndUserUuid(String topicUuid, String userUuid);
@Query("SELECT * FROM tb_progress WHERE capsule_uuid = :capsuleUuid AND type = 'c' LIMIT 1")
Progress selectByCapsuleUuid(String capsuleUuid);
@Query("SELECT * FROM tb_progress WHERE user_uuid = :userUuid AND type = 'c' AND completed = 0 AND progress <= 100 ORDER BY updated_on DESC LIMIT 1")
Progress selectLastCapsule(String userUuid);
@Query("SELECT * FROM tb_progress WHERE type = 'c' AND completed = 0 AND progress <= 100 ORDER BY updated_on ")
List<Progress> selectAllCapsulesInProgress();
@Query("SELECT * FROM tb_progress WHERE type = 'c' AND completed = 1 AND progress >= 100 ORDER BY updated_on ")
List<Progress> selectAllCapsulesCompleted();
@Query("SELECT * FROM tb_progress WHERE capsule_uuid = :capsuleUuid AND user_uuid = :userUuid AND type = 'c' LIMIT 1")
Progress selectByCapsuleUuidAndUserUuid(String capsuleUuid, String userUuid);
@Query("SELECT * FROM tb_progress WHERE slide_uuid = :slideUuid AND type = 's' LIMIT 1")
Progress selectBySlideUuid(String slideUuid);
@Query("SELECT * FROM tb_progress WHERE slide_uuid = :slideUuid AND user_uuid = :userUuid AND type = 's' LIMIT 1")
Progress selectBySlideUuidAndUserUuid(String slideUuid, String userUuid);
@Insert
void insert(Progress progress);
@Update
void update(Progress progress);
@Query("DELETE FROM tb_progress WHERE id = :id")
void remove(int id);
@Query("DELETE FROM tb_progress WHERE user_uuid != :userUuid")
void removeAllUserUuidNotEqual(String userUuid);
@Query("DELETE FROM tb_progress")
void removeAll();
}