artists: make artist finder use url instead of normalized_url.
Make the artist finder search for artists using the `url` field instead
of the `normalized_url` field. This lets us get rid of `normalized_url`
in the future.
As described in 10dac3ee5, artist URLs have both a `url` column and a
`normalized_url` column. The `normalized_url` column was the one used
for artist finding. The `url` was secretly normalized behind the scenes
so that artist finding would work no matter how the URL was written in
the artist entry. This is no longer necessary now that URLs are directly
normalized in artist entries.
This fixes various cases where artist finding didn't work for non-obvious
reasons, usually because the URL wasn't written in the right format so
it wasn't properly normalized behind the scenes.
This also makes it so that artist finding is case-insensitive, which
fixes #4821. Hopefully no sites are perverse enough to allow two
different usernames that differ only in case.
Users running their own Danbooru instance may have to fix the URLs in
their artist entries for artist finding to work again. There are a few
fix scripts to help with this:
* script/fixes/104_normalize_weibo_artist_urls.rb
* script/fixes/105_normalize_pixiv_artist_urls.rb
* script/fixes/106_normalize_artist_urls.rb
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
class AddLowerURLIndexToArtistURLs < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
# This index is used by the ArtistFinder.
|
||||
#
|
||||
# regexp_replace(lower('https://www.twitter.com/DanbooruBot'), '^https?://|/$', '', 'g') || '/'
|
||||
# => 'www.twitter.com/danboorubot/'
|
||||
add_index :artist_urls, "(regexp_replace(lower(artist_urls.url), '^https?://|/$', '', 'g') || '/') text_pattern_ops", name: :index_artist_urls_on_regexp_replace_lower_url, algorithm: :concurrently
|
||||
end
|
||||
end
|
||||
@@ -3139,6 +3139,13 @@ CREATE INDEX index_artist_urls_on_normalized_url_pattern ON public.artist_urls U
|
||||
CREATE INDEX index_artist_urls_on_normalized_url_trgm ON public.artist_urls USING gin (normalized_url public.gin_trgm_ops);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_artist_urls_on_regexp_replace_lower_url; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_artist_urls_on_regexp_replace_lower_url ON public.artist_urls USING btree (((regexp_replace(lower(url), '^https?://|/$'::text, ''::text, 'g'::text) || '/'::text)) text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_artist_urls_on_url_trgm; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -5779,6 +5786,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20220207195123'),
|
||||
('20220210171310'),
|
||||
('20220210200157'),
|
||||
('20220211075129');
|
||||
('20220211075129'),
|
||||
('20220318082614');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user