Skip to content
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

[#11843] Create Logic and Db layer for FeedbackSessionLogs #12914

Merged
merged 26 commits into from
Mar 28, 2024

Conversation

dishenggg
Copy link
Contributor

@dishenggg dishenggg commented Mar 19, 2024

Part of #11843

Outline of Solution

  • Create Logic and Db layer for FeedbackSessionLogs

Edit:

  • Update GCP to log student and session id for migrated courses

@dishenggg dishenggg marked this pull request as ready for review March 24, 2024 10:59
@FergusMok FergusMok added the s.ToReview The PR is waiting for review(s) label Mar 25, 2024
Copy link
Contributor

@FergusMok FergusMok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on the code, mostly just some requirement and optimization comments

Comment on lines 51 to 52
Student student = sqlLogic.getStudentForEmail(courseId, email);
FeedbackSession feedbackSession = sqlLogic.getFeedbackSession(fbSessionName, courseId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am somewhat worried about the performance of this.

We'll be making 2 queries per log entry, and it's possible that there will be many log entries even with the spam filter.

Apart from the time taken, it may incur alot of reads, making this feature quite expensive.

I think it's possible to optimize this, seeing that there's a higher probability that in an hour, the logs belong to the same feedbacksession / student

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's an optimization problem, it's fine to leave a comment and improve on it later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Since there is a high probability that the logs belong to the same student/session, I have updated the action to store queried students and feedback sessions in a map.

Copy link
Contributor Author

@dishenggg dishenggg Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have changed the logs to store the ids, I changed it to use getReference().

This should make it such that we incur 0 db reads for this part.

Edit:
Since the ids are not validated anywhere we probably need a way to catch the error thrown so other logs will still get created. Can't quite figure out how yet since the error cant seem to be caught by wrapping fslDb.createFeedbackSessionLog() in a try catch

private final String studentEmail;
private final String feedbackSessionName;
private final String feedbackSessionLogType;
private final long timestamp;

public FeedbackSessionLogEntry(String studentEmail, String feedbackSessionName,
String feedbackSessionLogType, long timestamp) {
public FeedbackSessionLogEntry(String courseId, String studentEmail,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cedricongjh Should GCP log the student's email? I think you mentioned that email is possible to change. If email changes, may break the updating action in future

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, good point, we should also change the log's format, to log studentId and feedbackSessionId as well, this way, when creating the Entity in SQL, we would only need to query by Id.

For GetFeedbackSessionLogsAction, we should be using studentId and feedbackSessionId too (instead of email and feedbackSessionName)

This will require FE changes (to change the logs format, as well as API request params), so let's change the BE here first and do the FE in a separate PR

Comment on lines +47 to +48
Student student = sqlLogic.getStudentForEmail(courseId, studentEmail);
FeedbackSession feedbackSession = sqlLogic.getFeedbackSession(fsName, courseId);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inorder to log the student and session ids it would incur additional reads on the creation of every log in GCP.

One idea around this is we can update other APIs to pass student/session ids to the frontend so this API can get the ids from the params?

Copy link
Contributor

@cedricongjh cedricongjh Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, let's do that! do note that non-migrated courses will not have these attributes, so they will need to set these to null. The frontend will then need to handle this when logging

@dishenggg dishenggg self-assigned this Mar 27, 2024
@dishenggg dishenggg removed the s.ToReview The PR is waiting for review(s) label Mar 27, 2024
@dishenggg dishenggg added the s.Ongoing The PR is being worked on by the author(s) label Mar 27, 2024
@dishenggg dishenggg added s.ToReview The PR is waiting for review(s) and removed s.Ongoing The PR is being worked on by the author(s) labels Mar 28, 2024
Copy link
Contributor

@FergusMok FergusMok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on the change! Just a very small thing

Copy link
Contributor

@cedricongjh cedricongjh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the hard work on this!

@cedricongjh cedricongjh merged commit ccad41b into TEAMMATES:student-activity-logs Mar 28, 2024
1 check passed
@cedricongjh cedricongjh added this to the V9.0.0-beta.5 milestone Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s.ToReview The PR is waiting for review(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants