Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom-dependency-tree.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ai.elimu:webapp:war:2.6.65-SNAPSHOT
ai.elimu:webapp:war:2.6.66-SNAPSHOT
+- ai.elimu:model:jar:model-2.0.113:compile
| \- com.google.code.gson:gson:jar:2.13.1:compile
| \- com.google.errorprone:error_prone_annotations:jar:2.38.0:compile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<Arg>discord_webhook_url</Arg>
<Arg>**********</Arg>
</Call>
<Call name="setAttribute">
<Arg>discord_analytics_webhook_url</Arg>
<Arg>**********</Arg>
</Call>
<Call name="setAttribute">
<Arg>github_lfs_token</Arg>
<Arg>**********</Arg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<Arg>discord_webhook_url</Arg>
<Arg>**********</Arg>
</Call>
<Call name="setAttribute">
<Arg>discord_analytics_webhook_url</Arg>
<Arg>**********</Arg>
</Call>
<Call name="setAttribute">
<Arg>github_lfs_token</Arg>
<Arg>**********</Arg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<Arg>discord_webhook_url</Arg>
<Arg>**********</Arg>
</Call>
<Call name="setAttribute">
<Arg>discord_analytics_webhook_url</Arg>
<Arg>**********</Arg>
</Call>
<Call name="setAttribute">
<Arg>github_lfs_token</Arg>
<Arg>**********</Arg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<Arg>discord_webhook_url</Arg>
<Arg>**********</Arg>
</Call>
<Call name="setAttribute">
<Arg>discord_analytics_webhook_url</Arg>
<Arg>**********</Arg>
</Call>
<Call name="setAttribute">
<Arg>github_lfs_token</Arg>
<Arg>**********</Arg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<Arg>discord_webhook_url</Arg>
<Arg>**********</Arg>
</Call>
<Call name="setAttribute">
<Arg>discord_analytics_webhook_url</Arg>
<Arg>**********</Arg>
</Call>
<Call name="setAttribute">
<Arg>github_lfs_token</Arg>
<Arg>**********</Arg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import ai.elimu.model.v2.enums.admin.ApplicationStatus;
import ai.elimu.util.ChecksumHelper;
import ai.elimu.util.ConfigHelper;
import ai.elimu.util.DiscordHelper;
import ai.elimu.util.DomainHelper;
import ai.elimu.util.DiscordHelper.Channel;
import ai.elimu.web.application.application_version.ApplicationVersionCreateController;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -164,12 +167,16 @@ public String handlePutRequest(
jsonResponseObject.put("result", "success");
jsonResponseObject.put("successMessage", "The application version was published with versionName " + applicationVersion.getVersionName());
response.setStatus(HttpStatus.OK.value());

DiscordHelper.postToChannel(Channel.ANALYTICS, "New application version distributed: " + DomainHelper.getBaseUrl() + "/application/edit/" + application.getId());
} catch (Exception ex) {
log.error(ex.getClass() + ": " + ex.getMessage(), ex);

jsonResponseObject.put("result", "error");
jsonResponseObject.put("errorMessage", ex.getClass() + ": " + ex.getMessage());
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());

DiscordHelper.postToChannel(Channel.ANALYTICS, "Application version distribution failed: `" + ex.getClass() + ": " + ex.getMessage() + "`");
}

String jsonResponse = jsonResponseObject.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,61 +54,66 @@ public class LetterSoundAssessmentEventImportScheduler {
public synchronized void execute() {
log.info("execute");

// Lookup CSV files stored on the filesystem
File elimuAiDir = new File(System.getProperty("user.home"), ".elimu-ai");
File languageDir = new File(elimuAiDir, "lang-" + Language.valueOf(ConfigHelper.getProperty("content.language")));
File analyticsDir = new File(languageDir, "analytics");
log.info("analyticsDir: " + analyticsDir);
analyticsDir.mkdirs();
for (File analyticsDirFile : analyticsDir.listFiles()) {
if (analyticsDirFile.getName().startsWith("android-id-")) {
File androidIdDir = new File(analyticsDir, analyticsDirFile.getName());
for (File androidIdDirFile : androidIdDir.listFiles()) {
Long studentId = null;
Integer eventImportCount = 0;
if (androidIdDirFile.getName().equals("letter-sound-assessment-events")) {
File letterSoundAssessmentEventsDir = new File(androidIdDir, androidIdDirFile.getName());
for (File csvFile : letterSoundAssessmentEventsDir.listFiles()) {
log.info("csvFile: " + csvFile);
try {
// Lookup CSV files stored on the filesystem
File elimuAiDir = new File(System.getProperty("user.home"), ".elimu-ai");
File languageDir = new File(elimuAiDir, "lang-" + Language.valueOf(ConfigHelper.getProperty("content.language")));
File analyticsDir = new File(languageDir, "analytics");
log.info("analyticsDir: " + analyticsDir);
analyticsDir.mkdirs();
for (File analyticsDirFile : analyticsDir.listFiles()) {
if (analyticsDirFile.getName().startsWith("android-id-")) {
File androidIdDir = new File(analyticsDir, analyticsDirFile.getName());
for (File androidIdDirFile : androidIdDir.listFiles()) {
Long studentId = null;
Integer eventImportCount = 0;
if (androidIdDirFile.getName().equals("letter-sound-assessment-events")) {
File letterSoundAssessmentEventsDir = new File(androidIdDir, androidIdDirFile.getName());
for (File csvFile : letterSoundAssessmentEventsDir.listFiles()) {
log.info("csvFile: " + csvFile);

// Convert from CSV to Java
List<LetterSoundAssessmentEvent> events = CsvAnalyticsExtractionHelper.extractLetterSoundAssessmentEvents(csvFile);
log.info("events.size(): " + events.size());
// Convert from CSV to Java
List<LetterSoundAssessmentEvent> events = CsvAnalyticsExtractionHelper.extractLetterSoundAssessmentEvents(csvFile);
log.info("events.size(): " + events.size());

// Store in database
for (LetterSoundAssessmentEvent event : events) {
// Check if the event has already been stored in the database
LetterSoundAssessmentEvent existingLetterSoundAssessmentEvent = letterSoundAssessmentEventDao.read(event.getTimestamp(), event.getAndroidId(), event.getPackageName());
if (existingLetterSoundAssessmentEvent != null) {
log.warn("The event has already been stored in the database. Skipping data import.");
continue;
}
// Store in database
for (LetterSoundAssessmentEvent event : events) {
// Check if the event has already been stored in the database
LetterSoundAssessmentEvent existingLetterSoundAssessmentEvent = letterSoundAssessmentEventDao.read(event.getTimestamp(), event.getAndroidId(), event.getPackageName());
if (existingLetterSoundAssessmentEvent != null) {
log.warn("The event has already been stored in the database. Skipping data import.");
continue;
}

// Generate Student ID
Student existingStudent = studentDao.read(event.getAndroidId());
if (existingStudent == null) {
Student student = new Student();
student.setAndroidId(event.getAndroidId());
studentDao.create(student);
log.info("Stored Student in database with ID " + student.getId());
studentId = student.getId();
} else {
studentId = existingStudent.getId();
}
// Generate Student ID
Student existingStudent = studentDao.read(event.getAndroidId());
if (existingStudent == null) {
Student student = new Student();
student.setAndroidId(event.getAndroidId());
studentDao.create(student);
log.info("Stored Student in database with ID " + student.getId());
studentId = student.getId();
} else {
studentId = existingStudent.getId();
}

// Store the event in the database
letterSoundAssessmentEventDao.create(event);
log.info("Stored event in database with ID " + event.getId());
eventImportCount++;
// Store the event in the database
letterSoundAssessmentEventDao.create(event);
log.info("Stored event in database with ID " + event.getId());
eventImportCount++;
}
}
}
}
if ((studentId != null) && (eventImportCount > 0)) {
String contentUrl = DomainHelper.getBaseUrl() + "/analytics/students/" + studentId;
DiscordHelper.postToChannel(Channel.ANALYTICS, "Imported " + eventImportCount + " letter-sound assessment events: " + contentUrl);
if ((studentId != null) && (eventImportCount > 0)) {
String contentUrl = DomainHelper.getBaseUrl() + "/analytics/students/" + studentId;
DiscordHelper.postToChannel(Channel.ANALYTICS, "Imported " + eventImportCount + " letter-sound assessment events: " + contentUrl);
}
}
}
}
} catch (Exception e) {
log.error("Error during data import:", e);
DiscordHelper.postToChannel(Channel.ANALYTICS, "Error during data import: `" + e.getClass() + ": " + e.getMessage() + "`");
}

log.info("execute complete");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,61 +54,66 @@ public class LetterSoundLearningEventImportScheduler {
public synchronized void execute() {
log.info("execute");

// Lookup CSV files stored on the filesystem
File elimuAiDir = new File(System.getProperty("user.home"), ".elimu-ai");
File languageDir = new File(elimuAiDir, "lang-" + Language.valueOf(ConfigHelper.getProperty("content.language")));
File analyticsDir = new File(languageDir, "analytics");
log.info("analyticsDir: " + analyticsDir);
analyticsDir.mkdirs();
for (File analyticsDirFile : analyticsDir.listFiles()) {
if (analyticsDirFile.getName().startsWith("android-id-")) {
File androidIdDir = new File(analyticsDir, analyticsDirFile.getName());
for (File androidIdDirFile : androidIdDir.listFiles()) {
Long studentId = null;
Integer eventImportCount = 0;
if (androidIdDirFile.getName().equals("letter-sound-learning-events")) {
File letterSoundLearningEventsDir = new File(androidIdDir, androidIdDirFile.getName());
for (File csvFile : letterSoundLearningEventsDir.listFiles()) {
log.info("csvFile: " + csvFile);
try {
// Lookup CSV files stored on the filesystem
File elimuAiDir = new File(System.getProperty("user.home"), ".elimu-ai");
File languageDir = new File(elimuAiDir, "lang-" + Language.valueOf(ConfigHelper.getProperty("content.language")));
File analyticsDir = new File(languageDir, "analytics");
log.info("analyticsDir: " + analyticsDir);
analyticsDir.mkdirs();
for (File analyticsDirFile : analyticsDir.listFiles()) {
if (analyticsDirFile.getName().startsWith("android-id-")) {
File androidIdDir = new File(analyticsDir, analyticsDirFile.getName());
for (File androidIdDirFile : androidIdDir.listFiles()) {
Long studentId = null;
Integer eventImportCount = 0;
if (androidIdDirFile.getName().equals("letter-sound-learning-events")) {
File letterSoundLearningEventsDir = new File(androidIdDir, androidIdDirFile.getName());
for (File csvFile : letterSoundLearningEventsDir.listFiles()) {
log.info("csvFile: " + csvFile);

// Convert from CSV to Java
List<LetterSoundLearningEvent> events = CsvAnalyticsExtractionHelper.extractLetterSoundLearningEvents(csvFile);
log.info("events.size(): " + events.size());
// Convert from CSV to Java
List<LetterSoundLearningEvent> events = CsvAnalyticsExtractionHelper.extractLetterSoundLearningEvents(csvFile);
log.info("events.size(): " + events.size());

// Store in database
for (LetterSoundLearningEvent event : events) {
// Check if the event has already been stored in the database
LetterSoundLearningEvent existingLetterSoundLearningEvent = letterSoundLearningEventDao.read(event.getTimestamp(), event.getAndroidId(), event.getPackageName());
if (existingLetterSoundLearningEvent != null) {
log.warn("The event has already been stored in the database. Skipping data import.");
continue;
}
// Store in database
for (LetterSoundLearningEvent event : events) {
// Check if the event has already been stored in the database
LetterSoundLearningEvent existingLetterSoundLearningEvent = letterSoundLearningEventDao.read(event.getTimestamp(), event.getAndroidId(), event.getPackageName());
if (existingLetterSoundLearningEvent != null) {
log.warn("The event has already been stored in the database. Skipping data import.");
continue;
}

// Generate Student ID
Student existingStudent = studentDao.read(event.getAndroidId());
if (existingStudent == null) {
Student student = new Student();
student.setAndroidId(event.getAndroidId());
studentDao.create(student);
log.info("Stored Student in database with ID " + student.getId());
studentId = student.getId();
} else {
studentId = existingStudent.getId();
}
// Generate Student ID
Student existingStudent = studentDao.read(event.getAndroidId());
if (existingStudent == null) {
Student student = new Student();
student.setAndroidId(event.getAndroidId());
studentDao.create(student);
log.info("Stored Student in database with ID " + student.getId());
studentId = student.getId();
} else {
studentId = existingStudent.getId();
}

// Store the event in the database
letterSoundLearningEventDao.create(event);
log.info("Stored event in database with ID " + event.getId());
eventImportCount++;
// Store the event in the database
letterSoundLearningEventDao.create(event);
log.info("Stored event in database with ID " + event.getId());
eventImportCount++;
}
}
}
}
if ((studentId != null) && (eventImportCount > 0)) {
String contentUrl = DomainHelper.getBaseUrl() + "/analytics/students/" + studentId;
DiscordHelper.postToChannel(Channel.ANALYTICS, "Imported " + eventImportCount + " letter-sound learning events: " + contentUrl);
if ((studentId != null) && (eventImportCount > 0)) {
String contentUrl = DomainHelper.getBaseUrl() + "/analytics/students/" + studentId;
DiscordHelper.postToChannel(Channel.ANALYTICS, "Imported " + eventImportCount + " letter-sound learning events: " + contentUrl);
}
}
}
}
} catch (Exception e) {
log.error("Error during data import:", e);
DiscordHelper.postToChannel(Channel.ANALYTICS, "Error during data import: `" + e.getClass() + ": " + e.getMessage() + "`");
}

log.info("execute complete");
Expand Down
Loading
Loading