fixes #2319: Artist search - NicoSeiga - not finding artist entries from partial URLs

This commit is contained in:
r888888888
2015-08-07 15:09:30 -07:00
parent 5bc0eea161
commit a9502c0dc2
3 changed files with 16 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ class ArtistUrl < ActiveRecord::Base
url = url.gsub(/^http:\/\/blog\d+\.fc2/, "http://blog.fc2")
url = url.gsub(/^http:\/\/blog-imgs-\d+\.fc2/, "http://blog.fc2")
url = url.gsub(/^http:\/\/blog-imgs-\d+-\w+\.fc2/, "http://blog.fc2")
url = url.sub(%r!(http://seiga.nicovideo.jp/user/illust/\d+)\?.+!, '\1')
begin
url = Sources::Site.new(url).normalize_for_artist_finder!
rescue PixivApiClient::Error

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
CurrentUser.user = User.admins.first
CurrentUser.ip_addr = "127.0.0.1"
ArtistUrl.update_all("normalized_url = replace(normalized_url, '?target=illust_all/', '/')", "normalized_url like 'http://seiga.nicovideo.jp/user/illust/%'")

View File

@@ -39,6 +39,11 @@ class ArtistUrlTest < ActiveSupport::TestCase
assert_equal("http://blog.fc2.com/monet/", url.normalized_url)
end
should "normalize nico seiga artist urls" do
url = FactoryGirl.create(:artist_url, :url => "http://seiga.nicovideo.jp/user/illust/1826959?target=illust_all")
assert_equal("http://seiga.nicovideo.jp/user/illust/1826959/", url.normalized_url)
end
should "normalize pixiv urls" do
url = FactoryGirl.create(:artist_url, :url => "http://img55.pixiv.net/img/monet")
assert_equal("http://img55.pixiv.net/img/monet", url.url)