bug fixes
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
module PostSets
|
module PostSets
|
||||||
class Artist < Post
|
class Artist < PostSets::Post
|
||||||
attr_reader :artist
|
attr_reader :artist
|
||||||
|
|
||||||
def initialize(artist)
|
def initialize(artist)
|
||||||
|
|||||||
@@ -309,6 +309,7 @@ class Tag < ActiveRecord::Base
|
|||||||
|
|
||||||
module RelationMethods
|
module RelationMethods
|
||||||
def update_related
|
def update_related
|
||||||
|
return unless should_update_related?
|
||||||
counts = RelatedTagCalculator.calculate_from_sample(Danbooru.config.post_sample_size, name)
|
counts = RelatedTagCalculator.calculate_from_sample(Danbooru.config.post_sample_size, name)
|
||||||
update_attributes(:related_tags => RelatedTagCalculator.convert_hash_to_string(counts), :related_tags_updated_at => Time.now)
|
update_attributes(:related_tags => RelatedTagCalculator.convert_hash_to_string(counts), :related_tags_updated_at => Time.now)
|
||||||
end
|
end
|
||||||
@@ -331,7 +332,8 @@ class Tag < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def related_tag_array
|
def related_tag_array
|
||||||
related_tags.split(/ /).in_groups_of(2)
|
update_related_if_outdated
|
||||||
|
related_tags.to_s.split(/ /).in_groups_of(2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -354,5 +356,6 @@ class Tag < ActiveRecord::Base
|
|||||||
extend StatisticsMethods
|
extend StatisticsMethods
|
||||||
include NameMethods
|
include NameMethods
|
||||||
extend ParseMethods
|
extend ParseMethods
|
||||||
|
include RelationMethods
|
||||||
extend SuggestionMethods
|
extend SuggestionMethods
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,11 +4,18 @@ module PostSetPresenters
|
|||||||
|
|
||||||
def initialize(post_set)
|
def initialize(post_set)
|
||||||
@post_set = post_set
|
@post_set = post_set
|
||||||
@tag_set_presenter = TagSetPresenter.new(
|
@tag_set_presenter = TagSetPresenter.new(related_tags)
|
||||||
RelatedTagCalculator.calculate_from_sample_to_array(
|
end
|
||||||
post_set.tag_string
|
|
||||||
).map {|x| x[0]}
|
def related_tags
|
||||||
)
|
if post_set.is_single_tag?
|
||||||
|
tag = Tag.find_by_name(post_set.tag_string)
|
||||||
|
if tag
|
||||||
|
return tag.related_tag_array.map(&:first)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
RelatedTagCalculator.calculate_from_sample_to_array(post_set.tag_string).map(&:first)
|
||||||
end
|
end
|
||||||
|
|
||||||
def posts
|
def posts
|
||||||
|
|||||||
Reference in New Issue
Block a user