-
-
Notifications
You must be signed in to change notification settings - Fork 69
feat: add student entity #2186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: add student entity #2186
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dc4efd6
feat: add student entity
jo-elimu d0d846f
log: check if file exists
jo-elimu 701a411
fix: switch from temporary to permanent file storage
jo-elimu 8b761f3
feat: generate student id during data collection
jo-elimu a9c29c2
feat: student id analytics dashboard
jo-elimu c117eba
feat: student id analytics dashboard
jo-elimu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package ai.elimu.dao; | ||
|
|
||
| import org.springframework.dao.DataAccessException; | ||
| import ai.elimu.entity.analytics.students.Student; | ||
|
|
||
| public interface StudentDao extends GenericDao<Student> { | ||
|
|
||
| Student read(String androidId) throws DataAccessException; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package ai.elimu.dao.jpa; | ||
|
|
||
| import jakarta.persistence.NoResultException; | ||
| import ai.elimu.dao.StudentDao; | ||
| import ai.elimu.entity.analytics.students.Student; | ||
| import org.springframework.dao.DataAccessException; | ||
|
|
||
| public class StudentDaoJpa extends GenericDaoJpa<Student> implements StudentDao { | ||
|
|
||
| @Override | ||
| public Student read(String androidId) throws DataAccessException { | ||
| try { | ||
| return (Student) em.createQuery( | ||
| "SELECT s " + | ||
| "FROM Student s " + | ||
| "WHERE s.androidId = :androidId") | ||
| .setParameter("androidId", androidId) | ||
| .getSingleResult(); | ||
| } catch (NoResultException e) { | ||
| return null; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| @Entity | ||
| @Getter | ||
| @Setter | ||
| @Deprecated | ||
| public class Device extends BaseEntity { | ||
|
|
||
| @NotNull | ||
|
|
||
24 changes: 24 additions & 0 deletions
24
src/main/java/ai/elimu/entity/analytics/students/Student.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package ai.elimu.entity.analytics.students; | ||
|
|
||
| import ai.elimu.entity.BaseEntity; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @Setter | ||
| public class Student extends BaseEntity { | ||
|
|
||
| /** | ||
| * A 64-bit number (expressed as a hexadecimal string), unique to each combination of | ||
| * app-signing key, user, and device. | ||
| * | ||
| * See https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID | ||
| */ | ||
| @NotNull | ||
| @Column(unique = true) | ||
| private String androidId; | ||
| } |
36 changes: 36 additions & 0 deletions
36
src/main/java/ai/elimu/web/analytics/students/StudentsListController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package ai.elimu.web.analytics.students; | ||
|
|
||
| import ai.elimu.dao.StudentDao; | ||
| import ai.elimu.entity.analytics.students.Student; | ||
| import ai.elimu.util.AnalyticsHelper; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Controller; | ||
| import org.springframework.ui.Model; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
|
|
||
| @Controller | ||
| @RequestMapping("/analytics/students") | ||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class StudentsListController { | ||
|
|
||
| private final StudentDao studentDao; | ||
|
|
||
| @GetMapping | ||
| public String handleRequest(Model model) { | ||
| log.info("handleRequest"); | ||
|
|
||
| List<Student> students = studentDao.readAll(); | ||
| for (Student student : students) { | ||
| student.setAndroidId(AnalyticsHelper.redactAndroidId(student.getAndroidId())); | ||
| } | ||
| model.addAttribute("students", students); | ||
|
|
||
| return "analytics/students/list"; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <content:title> | ||
| Students (${fn:length(students)}) | ||
| </content:title> | ||
|
|
||
jo-elimu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <content:banner> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| <br /> | ||
| </content:banner> | ||
|
|
||
| <content:section cssId="studentsListPage"> | ||
| <div class="section row"> | ||
| <table class="bordered highlight"> | ||
| <thead> | ||
| <th>id</th> | ||
| <th>android_id</th> | ||
| </thead> | ||
jo-elimu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <tbody> | ||
| <c:forEach var="student" items="${students}"> | ||
| <tr class="student"> | ||
| <td> | ||
| <a href="<spring:url value='/analytics/students/${student.id}' />"> | ||
| 🎓 Student ${student.id} | ||
| </a> | ||
| </td> | ||
| <td> | ||
| <code>${student.androidId}</code> | ||
| </td> | ||
| </tr> | ||
| </c:forEach> | ||
jo-elimu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </tbody> | ||
| </table> | ||
| </div> | ||
| </content:section> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.