Commit c0547843 authored by r888888888's avatar r888888888

eliminate unused vars in search counters

parent 5ae37597
......@@ -23,8 +23,8 @@ module PostsHelper
if params[:ms] == "1" && @post_set.post_count == 0 && @post_set.is_single_tag?
session_id = session.id
verifier = ActiveSupport::MessageVerifier.new(Danbooru.config.reportbooru_key, serializer: JSON, digest: "SHA256")
sig = verifier.generate(",#{session_id}")
return render("posts/partials/index/missed_search_count", session_id: session_id, sig: sig)
sig = verifier.generate("#{params[:tags]},#{session_id}")
return render("posts/partials/index/missed_search_count", sig: sig)
end
end
......@@ -39,7 +39,7 @@ module PostsHelper
value = session.id
verifier = ActiveSupport::MessageVerifier.new(Danbooru.config.reportbooru_key, serializer: JSON, digest: "SHA256")
sig = verifier.generate("#{key},#{value}")
return render("posts/partials/index/search_count", key: key, value: value, sig: sig)
return render("posts/partials/index/search_count", sig: sig)
end
end
......@@ -61,7 +61,7 @@ module PostsHelper
key = "uid"
value = user.id
verifier = ActiveSupport::MessageVerifier.new(Danbooru.config.reportbooru_key, serializer: JSON, digest: "SHA256")
verifier = ActiveSupporist::MessageVerifier.new(Danbooru.config.reportbooru_key, serializer: JSON, digest: "SHA256")
sig = verifier.generate("#{key},#{value}")
render("users/common_searches", user: user, sig: sig)
end
......
......@@ -26,7 +26,7 @@ class PopularSearchService
dates = date.strftime("%Y-%m-%d")
Cache.get("ps-day-#{dates}", 1.minute) do
url = "#{Danbooru.config.reportbooru_server}/hits/day?date=#{dates}"
url = "#{Danbooru.config.reportbooru_server}/post_searches/day?date=#{dates}"
response = HTTParty.get(url, Danbooru.config.httparty_options.reverse_merge(timeout: 3))
if response.success?
response = response.body
......
......@@ -2,8 +2,6 @@
$(function() {
var tags = $("#tags").val();
$.post("<%= Danbooru.config.reportbooru_server %>/missed_searches", {
session_id: "<%= session_id %>",
tags: tags,
sig: "<%= sig %>"
});
});
......
<script type="text/javascript">
$(function() {
$.post("<%= Danbooru.config.reportbooru_server %>/hits", {
key: "<%= key %>",
value: "<%= value %>",
<% if CurrentUser.user.is_platinum? %>
uid: <%= CurrentUser.user.id %>,
<% end %>
$.post("<%= Danbooru.config.reportbooru_server %>/post_searches", {
sig: "<%= sig %>"
});
});
......
module ReportbooruHelper
def mock_popular_search_service!
Danbooru.config.stubs(:reportbooru_server).returns("http://localhost:3003")
stub_request(:get, "http://localhost:3003/hits/month?date=#{Date.today}").to_return(body: "kantai_collection 1000.0\ntouhou 500.0")
stub_request(:get, "http://localhost:3003/hits/day?date=#{Date.today}").to_return(body: "kantai_collection 1000.0\ntouhou 500.0")
stub_request(:get, "http://localhost:3003/post_searches/month?date=#{Date.today}").to_return(body: "kantai_collection 1000.0\ntouhou 500.0")
stub_request(:get, "http://localhost:3003/post_searches/day?date=#{Date.today}").to_return(body: "kantai_collection 1000.0\ntouhou 500.0")
end
def mock_missed_search_service!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment