Proyectos de Subversion Android Microlearning - Inconcert

Rev

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

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