forked from e621ng/e621ng
[Users] Add about section search
This commit is contained in:
parent
2cd96817b0
commit
be0aa4960a
@ -136,7 +136,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def search_params
|
||||
permitted_params = %i[name_matches level min_level max_level can_upload_free can_approve_posts order]
|
||||
permitted_params = %i[name_matches about_me level min_level max_level can_upload_free can_approve_posts order]
|
||||
permitted_params += %i[ip_addr email_matches] if CurrentUser.is_admin?
|
||||
permit_search_params permitted_params
|
||||
end
|
||||
|
@ -798,11 +798,10 @@ class User < ApplicationRecord
|
||||
|
||||
q = q.search_text_attribute(:name, params)
|
||||
q = q.attribute_matches(:level, params[:level])
|
||||
# TODO: Doesn't support relation filtering using this method.
|
||||
# q = q.attribute_matches(:post_upload_count, params[:post_upload_count])
|
||||
# q = q.attribute_matches(:post_update_count, params[:post_update_count])
|
||||
# q = q.attribute_matches(:note_update_count, params[:note_update_count])
|
||||
# q = q.attribute_matches(:favorite_count, params[:favorite_count])
|
||||
|
||||
if params[:about_me].present?
|
||||
q = q.attribute_matches(:profile_about, params[:about_me]).or(attribute_matches(:profile_artinfo, params[:about_me]))
|
||||
end
|
||||
|
||||
if params[:email_matches].present?
|
||||
q = q.where_ilike(:email, params[:email_matches])
|
||||
|
@ -1,5 +1,6 @@
|
||||
<%= form_search(path: users_path) do |f| %>
|
||||
<%= f.input :name_matches, label: "Name", hint: "Use * for wildcard", autocomplete: "user" %>
|
||||
<%= f.input :about_me, label: "About", hint: "Use * for wildcard" %>
|
||||
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<%= f.input :email_matches, label: "Email", hint: "Use * for wildcard" %>
|
||||
|
8
db/migrate/20230518182034_add_user_about_indicies.rb
Normal file
8
db/migrate/20230518182034_add_user_about_indicies.rb
Normal file
@ -0,0 +1,8 @@
|
||||
class AddUserAboutIndicies < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
add_index :users, "(to_tsvector('english', profile_about))", using: :gin
|
||||
add_index :users, "(to_tsvector('english', profile_artinfo))", using: :gin
|
||||
execute("CREATE INDEX index_users_on_lower_profile_about_trgm ON users USING gin ((lower(profile_about)) gin_trgm_ops)")
|
||||
execute("CREATE INDEX index_users_on_lower_profile_artinfo_trgm ON users USING gin ((lower(profile_artinfo)) gin_trgm_ops)")
|
||||
end
|
||||
end
|
@ -4300,6 +4300,20 @@ CREATE INDEX index_users_on_email ON public.users USING btree (email);
|
||||
CREATE INDEX index_users_on_last_ip_addr ON public.users USING btree (last_ip_addr) WHERE (last_ip_addr IS NOT NULL);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_users_on_lower_profile_about_trgm; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_users_on_lower_profile_about_trgm ON public.users USING gin (lower(profile_about) public.gin_trgm_ops);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_users_on_lower_profile_artinfo_trgm; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_users_on_lower_profile_artinfo_trgm ON public.users USING gin (lower(profile_artinfo) public.gin_trgm_ops);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_users_on_name; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@ -4307,6 +4321,20 @@ CREATE INDEX index_users_on_last_ip_addr ON public.users USING btree (last_ip_ad
|
||||
CREATE UNIQUE INDEX index_users_on_name ON public.users USING btree (lower((name)::text));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_users_on_to_tsvector_english_profile_about; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_users_on_to_tsvector_english_profile_about ON public.users USING gin (to_tsvector('english'::regconfig, profile_about));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_users_on_to_tsvector_english_profile_artinfo; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_users_on_to_tsvector_english_profile_artinfo ON public.users USING gin (to_tsvector('english'::regconfig, profile_artinfo));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_wiki_page_versions_on_created_at; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@ -4704,6 +4732,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20230316084945'),
|
||||
('20230506161827'),
|
||||
('20230513074838'),
|
||||
('20230517155547');
|
||||
('20230517155547'),
|
||||
('20230518182034');
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user