-
Notifications
You must be signed in to change notification settings - Fork 78
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
Implement Soft-Delete for Students in Classes to Improve Performance #7588
Open
phungmanhcuong
wants to merge
11
commits into
master
Choose a base branch
from
mcphung/soft-delete-for-removing-student-from-class
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a0042a9
feat(student-course): Add soft-delete for student removal from course
phungmanhcuong 9f8f9b9
test(course): Add soft-delete tests and adapt existing tests to new b…
phungmanhcuong 8e5ec66
feat(invitation): handle soft-deleted student re-invitation to course
phungmanhcuong ba51368
revert(test): undo flaky test fix
phungmanhcuong 3ac47bc
chore(migration): add rollback for soft-delete migration
phungmanhcuong 7fe1db2
feat(user-registration): handle soft-deleted students in registration…
phungmanhcuong a61654c
refactor(course-user): remove soft-delete from associated models
phungmanhcuong f10ebc6
test(user-service): add missing test to improve coverage
phungmanhcuong 3f91dd2
chore(cleanup): remove outdated code
phungmanhcuong eb579dc
revert(course, achievement): remove soft-delete from Course and Achie…
phungmanhcuong 51bba68
fix(test): resolve flaky test in enrol_controller
phungmanhcuong 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -79,15 +79,17 @@ def restrict_invitee_role(users) | |
# @param [Hash] users The attributes from the client. | ||
# @return [Array<Hash>] Array of users to be invited | ||
def parse_from_form(users) | ||
users.map do |(_, value)| | ||
users.compact.map do |(_, value)| | ||
next if value.nil? | ||
|
||
name = value[:name].presence || value[:email] | ||
phantom = ActiveRecord::Type::Boolean.new.cast(value[:phantom]) | ||
{ name: name, | ||
email: value[:email], | ||
role: value[:role], | ||
phantom: phantom, | ||
timeline_algorithm: value[:timeline_algorithm] } | ||
end | ||
end.compact | ||
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. Why is there this change here? |
||
end | ||
|
||
# Loads the given file, and entries with blanks in either fields are ignored. | ||
|
This file contains 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 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
35 changes: 35 additions & 0 deletions
35
db/migrate/20241022035102_apply_soft_delete_for_course_user.rb
This file contains 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,35 @@ | ||
class ApplySoftDeleteForCourseUser < ActiveRecord::Migration[7.2] | ||
def up | ||
change_table :course_users do |t| | ||
t.datetime :deleted_at, default: nil unless column_exists?(:course_users, :deleted_at) | ||
t.index :deleted_at unless index_exists?(:course_users, :deleted_at) | ||
end | ||
|
||
change_table :courses do |t| | ||
t.datetime :deleted_at, default: nil unless column_exists?(:courses, :deleted_at) | ||
t.index :deleted_at unless index_exists?(:courses, :deleted_at) | ||
end | ||
|
||
change_table :course_achievements do |t| | ||
t.datetime :deleted_at, default: nil unless column_exists?(:course_achievements, :deleted_at) | ||
t.index :deleted_at unless index_exists?(:course_achievements, :deleted_at) | ||
Comment on lines
+13
to
+15
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. Why is there still |
||
end | ||
end | ||
|
||
def down | ||
change_table :course_users do |t| | ||
t.remove_index :deleted_at if index_exists?(:course_users, :deleted_at) | ||
t.remove :deleted_at if column_exists?(:course_users, :deleted_at) | ||
end | ||
|
||
change_table :courses do |t| | ||
t.remove_index :deleted_at if index_exists?(:courses, :deleted_at) | ||
t.remove :deleted_at if column_exists?(:courses, :deleted_at) | ||
end | ||
|
||
change_table :course_achievements do |t| | ||
t.remove_index :deleted_at if index_exists?(:course_achievements, :deleted_at) | ||
t.remove :deleted_at if column_exists?(:course_achievements, :deleted_at) | ||
end | ||
end | ||
end |
This file contains 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 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 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 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 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
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.
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.
The
paranoia
gem github page also recommended to look atdiscard
gemHave you taken a look at
discard
?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.
Learning the discard.