فهرست منبع

Caching fixes

Andrew 9 سال پیش
والد
کامیت
e37adbe385

+ 1 - 1
app/controllers/blazer/queries_controller.rb

@@ -67,7 +67,7 @@ module Blazer
         end
 
         @data_source = Blazer.data_sources[data_source]
-        @rows, @error, @cached_at = @data_source.run_statement(@statement, user: blazer_user, query: @query)
+        @rows, @error, @cached_at = @data_source.run_statement(@statement, user: blazer_user, query: @query, refresh_cache: params[:check])
 
         if @query && !@error.to_s.include?("canceling statement due to statement timeout")
           @query.checks.each do |check|

+ 1 - 1
app/views/blazer/checks/run.html.erb

@@ -1,7 +1,7 @@
 <p style="text-muted">Running check...</p>
 
 <script>
-  $.post("<%= run_queries_path %>", <%= json_escape({statement: @query.statement, query_id: @query.id}.to_json).html_safe %>, function (data) {
+  $.post("<%= run_queries_path %>", <%= json_escape({statement: @query.statement, query_id: @query.id, check: true}.to_json).html_safe %>, function (data) {
     setTimeout( function () {
       window.location.href = "<%= checks_path %>";
     }, 200);

+ 1 - 1
app/views/blazer/queries/_form.html.erb

@@ -111,7 +111,7 @@
     if (xhr) {
       xhr.abort();
     }
-    xhr = $.post("<%= run_queries_path %>", $.extend({}, params, {statement: editor.getValue(), data_source: $("#query_data_source").val()}), function (data) {
+    xhr = $.post("<%= run_queries_path %>", $.extend({}, params, {statement: editor.getValue().replace(/\n/g, "\r\n"), data_source: $("#query_data_source").val()}), function (data) {
       $("#results").html(data);
 
       error_line = /LINE (\d+)/g.exec($("#results").find('.alert-danger').text());

+ 1 - 1
app/views/blazer/queries/run.html.erb

@@ -10,7 +10,7 @@
   <% unless @only_chart %>
     <% if @cached_at %>
       <p class="text-muted" style="float: right;">
-        Cached <%= time_ago_in_words(@cached_at) %> ago
+        Cached <%= time_ago_in_words(@cached_at, include_seconds: true) %> ago
         <% if @query && !params[:data_source] %>
           <%= link_to "Refresh", refresh_query_path(@query, variable_params), method: :post %>
         <% end %>

+ 1 - 1
lib/blazer/data_source.rb

@@ -48,8 +48,8 @@ module Blazer
       rows = nil
       error = nil
       cached_at = nil
+      cache_key = self.cache_key(statement) if cache
       if cache && !options[:refresh_cache]
-        cache_key = self.cache_key(statement)
         value = Blazer.cache.read(cache_key)
         rows, cached_at = Marshal.load(value) if value
       end