Proyectos de Subversion Android Microlearning

Rev

Rev 43 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

package com.cesams.twogetskills.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Query;
import androidx.room.Insert;
import androidx.room.Update;

import com.cesams.twogetskills.entity.Progress;
import com.cesams.twogetskills.room.ResultCount;
import com.cesams.twogetskills.room.ResultTotalInt;

@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 * 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 user_uuid = :userUuid AND type = 'c' LIMIT 1")
    Progress selectByCapsuleUuidAndUserUuid(String capsuleUuid, String userUuid);

    @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();
    
}