fix logic for source searches
This commit is contained in:
@@ -45,7 +45,7 @@ module PostSets
|
|||||||
timeout = 3000
|
timeout = 3000
|
||||||
|
|
||||||
if tag_array.any? {|x| x =~ /^source:.*\*.*pixiv/}
|
if tag_array.any? {|x| x =~ /^source:.*\*.*pixiv/}
|
||||||
timeout = 300
|
timeout = 1000
|
||||||
end
|
end
|
||||||
|
|
||||||
@posts ||= begin
|
@posts ||= begin
|
||||||
|
|||||||
@@ -369,28 +369,24 @@ class Tag < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_related_if_outdated
|
def update_related_if_outdated
|
||||||
if should_update_related?
|
if should_update_related? && Delayed::Job.count < 200
|
||||||
if post_count < 100
|
delay(:queue => "default").update_related
|
||||||
update_related
|
|
||||||
else
|
|
||||||
delay(:queue => "default").update_related
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def related_cache_expiry
|
def related_cache_expiry
|
||||||
base = Math.sqrt([post_count, 0].max)
|
base = Math.sqrt([post_count, 0].max)
|
||||||
if base > 24
|
if base > 24 * 7
|
||||||
|
24 * 7
|
||||||
|
elsif base < 24
|
||||||
24
|
24
|
||||||
elsif base < 1
|
|
||||||
1
|
|
||||||
else
|
else
|
||||||
base
|
base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def should_update_related?
|
def should_update_related?
|
||||||
Delayed::Job.count < 200 && (related_tags.blank? || related_tags_updated_at.blank? || related_tags_updated_at < related_cache_expiry.hours.ago)
|
related_tags.blank? || related_tags_updated_at.blank? || related_tags_updated_at < related_cache_expiry.hours.ago
|
||||||
end
|
end
|
||||||
|
|
||||||
def related_tag_array
|
def related_tag_array
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
"title": "<%= j post.presenter.humanized_essential_tag_string %>"
|
"title": "<%= j post.presenter.humanized_essential_tag_string %>"
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="xhttp://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4f8dbf8a41066ac7"></script>
|
<script type="text/javascript" src="http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4f8dbf8a41066ac7"></script>
|
||||||
|
|
||||||
<!-- AddThis Button END -->
|
<!-- AddThis Button END -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user