dmails: replace hard deletions with soft deletions.
Turn deletions into soft deletions (set the is_deleted flag) instead of hard deletions (remove from database). The is_deleted flag actually already existed, but it was never used before.
This commit is contained in:
@@ -7,8 +7,10 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
extending(PaginationExtension).paginate(*options)
|
||||
end
|
||||
|
||||
def paginated_search(params, count_pages: params[:search].present?)
|
||||
def paginated_search(params, defaults: {}, count_pages: params[:search].present?)
|
||||
search_params = params.fetch(:search, {}).permit!
|
||||
search_params = defaults.merge(search_params).with_indifferent_access
|
||||
|
||||
search(search_params).paginate(params[:page], limit: params[:limit], search_count: count_pages)
|
||||
end
|
||||
end
|
||||
@@ -93,7 +95,7 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search_boolean_attribute(attribute, params)
|
||||
return all unless params[attribute]
|
||||
return all unless params.key?(attribute)
|
||||
|
||||
value = params[attribute].to_s
|
||||
if value.truthy?
|
||||
|
||||
@@ -136,8 +136,6 @@ class Dmail < ApplicationRecord
|
||||
q = q.text_attribute_matches(:title, params[:title_matches])
|
||||
q = q.text_attribute_matches(:body, params[:message_matches], index_column: :message_index)
|
||||
|
||||
params[:is_spam] = false unless params[:is_spam].present?
|
||||
|
||||
q = q.read if params[:read].to_s.truthy?
|
||||
q = q.unread if params[:read].to_s.falsy?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user