Browse Source

Added local_time_suffix setting

Andrew Kane 8 years ago
parent
commit
985f3c901a

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

@@ -212,9 +212,15 @@ module Blazer
           csv << rows.first.keys
         end
         rows.each do |row|
-          csv << row.values.map { |v| v.is_a?(Time) ? v.in_time_zone(Blazer.time_zone) : v }
+          csv << row.map { |k, v| v.is_a?(Time) ? blazer_time_value(k, v) : v }
         end
       end
     end
+
+    def blazer_time_value(k, v)
+      # yuck, instance var
+      @data_source.local_time_suffix.any? { |s| k.ends_with?(s) } ? v.to_s.sub(" UTC", "") : v.in_time_zone(Blazer.time_zone)
+    end
+    helper_method :blazer_time_value
   end
 end

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

@@ -98,7 +98,7 @@
                 <% row.each do |k, v| %>
                   <td>
                     <% if v.is_a?(Time) %>
-                      <% v = v.in_time_zone(Blazer.time_zone) %>
+                      <% v = blazer_time_value(k, v) %>
                     <% end %>
 
                     <% unless v.nil? %>

+ 4 - 0
lib/blazer/data_source.rb

@@ -40,6 +40,10 @@ module Blazer
       settings["cache"]
     end
 
+    def local_time_suffix
+      @local_time_suffix ||= Array(settings["local_time_suffix"])
+    end
+
     def use_transaction?
       settings.key?("use_transaction") ? settings["use_transaction"] : true
     end