Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

Rev 24 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 gabriel 1
package com.cesams.twogetskills.dao;
2
 
3
import androidx.room.Dao;
4
import androidx.room.Delete;
5
import androidx.room.Query;
6
import androidx.room.Insert;
7
import androidx.room.Update;
8
 
9
import com.cesams.twogetskills.entity.Progress;
10
import com.cesams.twogetskills.room.ResultCount;
11
import com.cesams.twogetskills.room.ResultTotalInt;
12
 
24 gabriel 13
import java.util.List;
14
 
1 gabriel 15
@Dao
16
public interface ProgressDao {
17
 
19 gabriel 18
    @Query("SELECT COUNT(*) AS count FROM tb_progress where topic_uuid = :topicUuid AND type = 's' AND completed = 1 AND user_uuid = :userUuid")
19
    ResultCount getCountSlidesCompletedByTopicUuidAndUserUuid(String topicUuid, String userUuid);
1 gabriel 20
 
19 gabriel 21
    @Query("SELECT COUNT(*) AS count FROM tb_progress where topic_uuid = :topicUuid AND type = 'c' AND completed = 1 AND user_uuid = :userUuid")
22
    ResultCount getCountCapsulesCompletedByTopicUuidAndUserUuid(String topicUuid, String userUuid);
1 gabriel 23
 
19 gabriel 24
    @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")
25
    ResultCount getCountCapsulesCompletedWithoutReturningByTopicUuidAndUserUuid(String topicUuid, String userUuid);
1 gabriel 26
 
19 gabriel 27
    @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")
28
    ResultTotalInt getCountCapsulesCompletedWithReturningByTopicUuidAndUserUuid(String topicUuid, String userUuid);
1 gabriel 29
 
19 gabriel 30
    @Query("SELECT COUNT(*) AS count FROM tb_progress where capsule_uuid = :capsuleUuid AND user_uuid = :userUuid AND type = 's' AND completed = 1")
31
    ResultCount getCountSlidesCompletedByCapsuleUuidAndUserUuid(String capsuleUuid, String userUuid);
1 gabriel 32
 
33
    @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")
34
    ResultTotalInt getCountCapsulesCompletedWithReturningByTopicUuid(String topicUuid);
35
 
36
    @Query("SELECT COUNT(*) AS count FROM tb_progress where capsule_uuid = :capsuleUuid AND type = 's' AND completed = 1")
37
    ResultCount getCountSlidesCompletedByCapsuleUuid(String capsuleUuid);
38
 
39
 
40
    @Query("SELECT * FROM tb_progress WHERE topic_uuid = :topicUuid AND type = 't' LIMIT 1")
41
    Progress selectByTopicUuid(String topicUuid);
42
 
43
    @Query("SELECT * FROM tb_progress WHERE topic_uuid = :topicUuid AND user_uuid = :userUuid AND type = 't' LIMIT 1")
44
    Progress  selectByTopicUuidAndUserUuid(String topicUuid, String userUuid);
45
 
46
    @Query("SELECT * FROM tb_progress WHERE capsule_uuid = :capsuleUuid AND type = 'c' LIMIT 1")
47
    Progress selectByCapsuleUuid(String capsuleUuid);
48
 
71 efrain 49
    @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")
50
    Progress selectLastCapsule(String userUuid);
24 gabriel 51
 
71 efrain 52
    @Query("SELECT * FROM tb_progress WHERE type = 'c' AND completed = 0 AND progress <= 100 ORDER BY updated_on ")
53
    List<Progress> selectAllCapsulesInProgress();
54
 
55
    @Query("SELECT * FROM tb_progress WHERE type = 'c' AND completed = 1 AND progress >= 100 ORDER BY updated_on ")
56
    List<Progress> selectAllCapsulesCompleted();
57
 
1 gabriel 58
    @Query("SELECT * FROM tb_progress WHERE capsule_uuid = :capsuleUuid AND user_uuid = :userUuid AND type = 'c' LIMIT 1")
59
    Progress selectByCapsuleUuidAndUserUuid(String capsuleUuid, String userUuid);
60
 
61
    @Query("SELECT * FROM tb_progress WHERE slide_uuid = :slideUuid AND type = 's' LIMIT 1")
62
    Progress selectBySlideUuid(String slideUuid);
63
 
64
    @Query("SELECT * FROM tb_progress WHERE slide_uuid = :slideUuid AND user_uuid = :userUuid AND type = 's' LIMIT 1")
65
    Progress selectBySlideUuidAndUserUuid(String slideUuid, String userUuid);
71 efrain 66
 
1 gabriel 67
    @Insert
68
    void insert(Progress progress);
69
 
70
    @Update
71
    void update(Progress progress);
72
 
73
    @Query("DELETE FROM tb_progress WHERE id = :id")
74
    void remove(int id);
75
 
19 gabriel 76
    @Query("DELETE FROM tb_progress WHERE user_uuid != :userUuid")
1 gabriel 77
    void removeAllUserUuidNotEqual(String userUuid);
78
 
79
    @Query("DELETE FROM tb_progress")
80
    void removeAll();
81
 
82
}