Proyectos de Subversion Android Microlearning - Inconcert

Rev

Ir a la última revisión | | 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
 
48
    @Query("SELECT * FROM tb_progress WHERE type = 'c' ORDER BY updated_on DESC")
49
    List<Progress> selectAllCapsulesProgress();
50
 
51
    @Query("SELECT * FROM tb_progress WHERE capsule_uuid = :capsuleUuid AND user_uuid = :userUuid AND type = 'c' LIMIT 1")
52
    Progress selectByCapsuleUuidAndUserUuid(String capsuleUuid, String userUuid);
53
 
54
    @Query("SELECT * FROM tb_progress WHERE slide_uuid = :slideUuid AND type = 's' LIMIT 1")
55
    Progress selectBySlideUuid(String slideUuid);
56
 
57
    @Query("SELECT * FROM tb_progress WHERE slide_uuid = :slideUuid AND user_uuid = :userUuid AND type = 's' LIMIT 1")
58
    Progress selectBySlideUuidAndUserUuid(String slideUuid, String userUuid);
59
    @Insert
60
    void insert(Progress progress);
61
 
62
    @Update
63
    void update(Progress progress);
64
 
65
    @Query("DELETE FROM tb_progress WHERE id = :id")
66
    void remove(int id);
67
 
68
    @Query("DELETE FROM tb_progress WHERE user_uuid != :userUuid")
69
    void removeAllUserUuidNotEqual(String userUuid);
70
 
71
    @Query("DELETE FROM tb_progress")
72
    void removeAll();
73
 
74
}