Skip to content

Commit 4ceb1b6

Browse files
authored
feat: delete storybooks (#2331)
2 parents ea11187 + 8e7685b commit 4ceb1b6

19 files changed

Lines changed: 175 additions & 69 deletions

pom-dependency-tree.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ai.elimu:webapp:war:2.6.120-SNAPSHOT
1+
ai.elimu:webapp:war:2.6.124-SNAPSHOT
22
+- ai.elimu:model:jar:model-2.0.120:compile
33
| \- com.google.code.gson:gson:jar:2.13.1:compile
44
| \- com.google.errorprone:error_prone_annotations:jar:2.38.0:compile

src/main/java/ai/elimu/dao/StoryBookLearningEventDao.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.springframework.dao.DataAccessException;
66

77
import ai.elimu.entity.analytics.StoryBookLearningEvent;
8+
import ai.elimu.entity.content.StoryBook;
89
import ai.elimu.model.v2.enums.analytics.research.ExperimentGroup;
910
import ai.elimu.model.v2.enums.analytics.research.ResearchExperiment;
1011

@@ -17,4 +18,6 @@ public interface StoryBookLearningEventDao extends GenericDao<StoryBookLearningE
1718
List<StoryBookLearningEvent> readAll(String androidId) throws DataAccessException;
1819

1920
List<StoryBookLearningEvent> readAll(ResearchExperiment researchExperiment, ExperimentGroup experimentGroup) throws DataAccessException;
21+
22+
List<StoryBookLearningEvent> readAll(StoryBook storyBook) throws DataAccessException;
2023
}

src/main/java/ai/elimu/dao/jpa/StoryBookLearningEventDaoJpa.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import ai.elimu.dao.StoryBookLearningEventDao;
44
import ai.elimu.entity.analytics.StoryBookLearningEvent;
5+
import ai.elimu.entity.content.StoryBook;
56
import ai.elimu.model.v2.enums.analytics.research.ExperimentGroup;
67
import ai.elimu.model.v2.enums.analytics.research.ResearchExperiment;
78

@@ -63,5 +64,16 @@ public List<StoryBookLearningEvent> readAll(ResearchExperiment researchExperimen
6364
.setParameter("researchExperiment", researchExperiment)
6465
.setParameter("experimentGroup", experimentGroup)
6566
.getResultList();
67+
}
68+
69+
@Override
70+
public List<StoryBookLearningEvent> readAll(StoryBook storyBook) throws DataAccessException {
71+
return em.createQuery(
72+
"SELECT event " +
73+
"FROM StoryBookLearningEvent event " +
74+
"WHERE event.storyBook = :storyBook " +
75+
"ORDER BY event.timestamp")
76+
.setParameter("storyBook", storyBook)
77+
.getResultList();
6678
}
6779
}

src/main/java/ai/elimu/entity/analytics/StoryBookLearningEvent.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
@Entity
1313
public class StoryBookLearningEvent extends LearningEvent {
1414

15-
private Long storyBookId;
15+
@NotNull
16+
private String storyBookTitle;
1617

17-
@NotNull
18-
private String storyBookTitle;
18+
private Long storyBookId;
1919

20-
/**
21-
* This field will only be populated if a corresponding {@link StoryBook} can be found in the database for the {@link #storyBookId}.
22-
*/
23-
@ManyToOne
24-
private StoryBook storyBook;
20+
/**
21+
* This field will only be populated if a corresponding {@link StoryBook}
22+
* can be found in the database for the {@link #storyBookId}.
23+
*/
24+
@ManyToOne
25+
private StoryBook storyBook;
2526
}

src/main/java/ai/elimu/tasks/LetterSoundUsageCountScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public synchronized void execute() {
4848
}
4949
} catch (Exception e) {
5050
log.error("Error in scheduled task:", e);
51-
DiscordHelper.postToChannel(Channel.CONTENT, "Error in `" + e.getClass() + ": " + e.getMessage() + "`");
51+
DiscordHelper.postToChannel(Channel.CONTENT, "Error in " + getClass().getSimpleName() + ":`" + e.getClass() + ": " + e.getMessage() + "`");
5252
}
5353

5454
log.info("execute complete");

src/main/java/ai/elimu/tasks/LetterUsageCountScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public synchronized void execute() {
4848
}
4949
} catch (Exception e) {
5050
log.error("Error in scheduled task:", e);
51-
DiscordHelper.postToChannel(Channel.CONTENT, "Error in `" + e.getClass() + ": " + e.getMessage() + "`");
51+
DiscordHelper.postToChannel(Channel.CONTENT, "Error in " + getClass().getSimpleName() + ":`" + e.getClass() + ": " + e.getMessage() + "`");
5252
}
5353

5454
log.info("execute complete");

src/main/java/ai/elimu/tasks/ParagraphWordScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public synchronized void execute() {
6767
storyBooksJsonService.refreshStoryBooksJSONArray();
6868
} catch (Exception e) {
6969
log.error("Error in scheduled task:", e);
70-
DiscordHelper.postToChannel(Channel.CONTENT, "Error in `" + e.getClass() + ": " + e.getMessage() + "`");
70+
DiscordHelper.postToChannel(Channel.CONTENT, "Error in " + getClass().getSimpleName() + ":`" + e.getClass() + ": " + e.getMessage() + "`");
7171
}
7272

7373
log.info("execute complete");

src/main/java/ai/elimu/tasks/SoundUsageCountScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public synchronized void execute() {
4848
}
4949
} catch (Exception e) {
5050
log.error("Error in scheduled task:", e);
51-
DiscordHelper.postToChannel(Channel.CONTENT, "Error in `" + e.getClass() + ": " + e.getMessage() + "`");
51+
DiscordHelper.postToChannel(Channel.CONTENT, "Error in " + getClass().getSimpleName() + ":`" + e.getClass() + ": " + e.getMessage() + "`");
5252
}
5353

5454
log.info("execute complete");

src/main/java/ai/elimu/tasks/SyllableUsageCountScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public synchronized void execute() {
100100
}
101101
} catch (Exception e) {
102102
log.error("Error in scheduled task:", e);
103-
DiscordHelper.postToChannel(Channel.CONTENT, "Error in `" + e.getClass() + ": " + e.getMessage() + "`");
103+
DiscordHelper.postToChannel(Channel.CONTENT, "Error in " + getClass().getSimpleName() + ":`" + e.getClass() + ": " + e.getMessage() + "`");
104104
}
105105

106106
log.info("execute complete");

src/main/java/ai/elimu/tasks/WordUsageCountScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public synchronized void execute() {
4949
}
5050
} catch (Exception e) {
5151
log.error("Error in scheduled task:", e);
52-
DiscordHelper.postToChannel(Channel.CONTENT, "Error in `" + e.getClass() + ": " + e.getMessage() + "`");
52+
DiscordHelper.postToChannel(Channel.CONTENT, "Error in " + getClass().getSimpleName() + ":`" + e.getClass() + ": " + e.getMessage() + "`");
5353
}
5454

5555
log.info("execute complete");

0 commit comments

Comments
 (0)