Proyectos de Subversion Android Microlearning

Rev

Ir a la última revisión | 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")
    ResultCount getCountSlidesCompletedByTopicUuid(String topicUuid);

    @Query("SELECT COUNT(*) AS count FROM tb_progress where topic_uuid = :topicUuid AND type = 'c' AND completed = 1")
    ResultCount getCountCapsulesCompletedByTopicUuid(String topicUuid);

    @Query("SELECT  COUNT(*) AS count FROM tb_progress where topic_uuid = :topicUuid AND type = 'c' AND completed = 1 AND returning_after_completed = 0")
    ResultCount getCountCapsulesCompletedWithoutReturningByTopicUuid(String topicUuid);

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