-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
feat(entity): video learning event #1911
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package ai.elimu.model.analytics; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.ManyToOne; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import ai.elimu.model.content.multimedia.Video; | ||
|
||
@Entity | ||
public class VideoLearningEvent extends LearningEvent { | ||
|
||
@NotNull | ||
private String videoTitle; | ||
|
||
/** | ||
* This field might not be included, e.g. if the videos were opened in a 3rd-party | ||
* app that did not load the videos from the elimu.ai Content Provider. In this | ||
* case, the {@link #videoId} will be {@code null}. | ||
*/ | ||
private Long videoId; | ||
|
||
/** | ||
* This field will only be populated if a corresponding {@link Video} can be | ||
* found in the database for a given {@link #videoId}. | ||
*/ | ||
@ManyToOne | ||
private Video video; | ||
|
||
public String getVideoTitle() { | ||
return videoTitle; | ||
} | ||
|
||
public void setVideoTitle(String videoTitle) { | ||
this.videoTitle = videoTitle; | ||
} | ||
|
||
public Long getVideoId() { | ||
return videoId; | ||
} | ||
|
||
public void setVideoId(Long videoId) { | ||
this.videoId = videoId; | ||
} | ||
|
||
public Video getVideo() { | ||
return video; | ||
} | ||
|
||
public void setVideo(Video video) { | ||
this.video = video; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,8 @@ | |
|
||
drop table if exists Video_Word; | ||
|
||
drop table if exists VideoLearningEvent; | ||
|
||
drop table if exists Word; | ||
|
||
drop table if exists Word_LetterSound; | ||
|
@@ -631,6 +633,19 @@ | |
primary key (Video_id, words_id) | ||
) engine=MyISAM; | ||
|
||
create table VideoLearningEvent ( | ||
id bigint not null auto_increment, | ||
androidId varchar(255), | ||
learningEventType varchar(255), | ||
packageName varchar(255), | ||
timestamp datetime, | ||
videoId bigint, | ||
videoTitle varchar(255), | ||
application_id bigint, | ||
video_id bigint, | ||
primary key (id) | ||
) engine=MyISAM; | ||
Comment on lines
+636
to
+647
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider optimizing the VideoLearningEvent table structure and engine. The new VideoLearningEvent table looks good overall, but there are a few points to consider:
Here's a suggested modification: create table VideoLearningEvent (
id bigint not null auto_increment,
androidId varchar(255),
learningEventType varchar(255),
packageName varchar(255),
timestamp datetime,
videoTitle varchar(255),
application_id bigint,
video_id bigint,
primary key (id)
) engine=InnoDB; This change removes the redundant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai How can I ensure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jo-elimu, to ensure that the Here's how you can update your @Entity
public class VideoLearningEvent extends LearningEvent {
@Column(nullable = false)
private String videoTitle;
@Column(nullable = false)
private Long videoId;
@ManyToOne
private Video video;
// Getters and setters...
} By setting After making these changes, regenerate the SQL schema using your build tool or ORM framework (e.g., running Let me know if you need further assistance! |
||
|
||
create table Word ( | ||
id bigint not null auto_increment, | ||
contentStatus varchar(255), | ||
|
@@ -1072,6 +1087,16 @@ | |
foreign key (Video_id) | ||
references Video (id); | ||
|
||
alter table VideoLearningEvent | ||
add constraint FKoqqhe1r2epyv55g6jo79t251h | ||
foreign key (application_id) | ||
references Application (id); | ||
|
||
alter table VideoLearningEvent | ||
add constraint FK38rllate5mtlhi6fdiudffm4c | ||
foreign key (video_id) | ||
references Video (id); | ||
|
||
alter table Word | ||
add constraint FKd1ussioi3bpu2tmxm0cim5s5a | ||
foreign key (rootWord_id) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider using Optional for videoId.
The
videoId
field can be null, as indicated by the comment. To make this more explicit in the type system and avoid potential null pointer exceptions, consider usingOptional<Long>
instead ofLong
.Here's a suggested change:
Remember to update the getter and setter methods accordingly if you make this change.
📝 Committable suggestion