コミットを比較
3 コミット
main
...
a59ec2b417
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
| a59ec2b417 | |||
| eef12a68d1 | |||
| 9f10bc8467 |
@@ -56,6 +56,12 @@ class Tag < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.no_deerjikist
|
||||||
|
@no_deerjikist ||= Tag.find_or_initialize_by(name: 'ニジラー情報不詳') do |tag|
|
||||||
|
tag.category = 'meta'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.normalise_tags tag_names, with_tagme: true
|
def self.normalise_tags tag_names, with_tagme: true
|
||||||
tags = tag_names.map do |name|
|
tags = tag_names.map do |name|
|
||||||
pf, cat = CATEGORY_PREFIXES.find { |p, _| name.start_with?(p) } || ['', nil]
|
pf, cat = CATEGORY_PREFIXES.find { |p, _| name.start_with?(p) } || ['', nil]
|
||||||
@@ -68,6 +74,7 @@ class Tag < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
tags << Tag.tagme if with_tagme && tags.size < 10 && tags.none?(Tag.tagme)
|
tags << Tag.tagme if with_tagme && tags.size < 10 && tags.none?(Tag.tagme)
|
||||||
|
tags << Tag.no_deerjikist if tags.all? { |t| t.category != 'deerjikist' }
|
||||||
tags.uniq
|
tags.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
namespace :nico do
|
namespace :nico do
|
||||||
desc 'ニコニコ DB 同期'
|
desc 'ニコニコ DB 同期'
|
||||||
task sync: :environment do
|
task sync: :environment do
|
||||||
|
require 'json'
|
||||||
|
require 'nokogiri'
|
||||||
require 'open3'
|
require 'open3'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
require 'nokogiri'
|
require 'set'
|
||||||
|
|
||||||
fetch_thumbnail = -> url do
|
fetch_thumbnail = -> url do
|
||||||
html = URI.open(url, read_timeout: 60, 'User-Agent' => 'Mozilla/5.0').read
|
html = URI.open(url, read_timeout: 60, 'User-Agent' => 'Mozilla/5.0').read
|
||||||
@@ -87,6 +89,9 @@ namespace :nico do
|
|||||||
if kept_non_nico_ids.to_set != desired_non_nico_ids.to_set
|
if kept_non_nico_ids.to_set != desired_non_nico_ids.to_set
|
||||||
desired_all_ids << Tag.bot.id
|
desired_all_ids << Tag.bot.id
|
||||||
end
|
end
|
||||||
|
unless Tag.where(id: desired_all_ids).where(category: 'deerjikist').exists?
|
||||||
|
desired_all_ids << Tag.no_deerjikist.id
|
||||||
|
end
|
||||||
desired_all_ids.uniq!
|
desired_all_ids.uniq!
|
||||||
|
|
||||||
sync_post_tags!(post, desired_all_ids)
|
sync_post_tags!(post, desired_all_ids)
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする