fix logic for source searches

This commit is contained in:
albert
2013-03-03 14:56:39 -05:00
parent 89c0ab86a8
commit 0137f7ff79
3 changed files with 8 additions and 12 deletions

View File

@@ -45,7 +45,7 @@ module PostSets
timeout = 3000
if tag_array.any? {|x| x =~ /^source:.*\*.*pixiv/}
timeout = 300
timeout = 1000
end
@posts ||= begin

View File

@@ -369,28 +369,24 @@ class Tag < ActiveRecord::Base
end
def update_related_if_outdated
if should_update_related?
if post_count < 100
update_related
else
delay(:queue => "default").update_related
end
if should_update_related? && Delayed::Job.count < 200
delay(:queue => "default").update_related
end
end
def related_cache_expiry
base = Math.sqrt([post_count, 0].max)
if base > 24
if base > 24 * 7
24 * 7
elsif base < 24
24
elsif base < 1
1
else
base
end
end
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
def related_tag_array

View File

@@ -14,7 +14,7 @@
"title": "<%= j post.presenter.humanized_essential_tag_string %>"
};
</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 -->
</div>