11517: Use count=none when retrieving logs.
authorTom Clegg <tom@curoverse.com>
Fri, 21 Apr 2017 19:17:46 +0000 (15:17 -0400)
committerTom Clegg <tom@curoverse.com>
Mon, 24 Apr 2017 14:04:29 +0000 (10:04 -0400)
apps/workbench/app/controllers/keep_disks_controller.rb
apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/models/arvados_base.rb
apps/workbench/app/models/arvados_resource_list.rb
apps/workbench/app/models/job.rb
apps/workbench/app/models/pipeline_instance.rb
apps/workbench/app/models/proxy_work_unit.rb

index f57455b37fd6895262267bfc75e2df8e6dced594..bbf18e591bbb5f873a0c680f248f06eb85f72cdc 100644 (file)
@@ -32,6 +32,7 @@ class KeepDisksController < ApplicationController
     histogram_log = Log.
       filter([[:event_type, '=', 'block-age-free-space-histogram']]).
       order(:created_at => :desc).
+      with_count('none').
       limit(1)
     histogram_log.each do |log_entry|
       # We expect this block to only execute at most once since we
index d2fcbbb94c7385def6753fb0feee877d9ad7f13d..1a1c5f802152ffe4cdb7ff009fce0bb02c70cbc1 100644 (file)
@@ -102,6 +102,7 @@ class UsersController < ApplicationController
         filter([[:object_uuid, '=', u.uuid],
                 [:event_type, '=', 'user-storage-report']]).
         order(:created_at => :desc).
+        with_count('none').
         limit(1)
       storage_log.each do |log_entry|
         # We expect this block to only execute once since we specified limit(1)
index 6250daa06a3d0c65d2233f51c33588a9de3855a5..5d6a4c94b9bebb581d771ce4b0557f3ba828e119 100644 (file)
@@ -144,6 +144,10 @@ class ArvadosBase < ActiveRecord::Base
     ArvadosResourceList.new(self).select(*args)
   end
 
+  def self.with_count(*args)
+    ArvadosResourceList.new(self).with_count(*args)
+  end
+
   def self.distinct(*args)
     ArvadosResourceList.new(self).distinct(*args)
   end
index 27069706fb36e1f5f56b2853ff0b93216e9637ae..e56d1981e35ac8c9cc178136f61db564097cbcf0 100644 (file)
@@ -84,6 +84,11 @@ class ArvadosResourceList
     self
   end
 
+  def with_count(count_param='exact')
+    @count = count_param
+    self
+  end
+
   def fetch_multiple_pages(f)
     @fetch_multiple_pages = f
     self
@@ -178,6 +183,7 @@ class ArvadosResourceList
     api_params = {
       _method: 'GET'
     }
+    api_params[:count] = @count if @count
     api_params[:where] = @cond if @cond
     api_params[:eager] = '1' if @eager
     api_params[:select] = @select if @select
index 346aef35d27b835fd54a018bfd6ce05ae83de0d9..128440d52612c7b748eb91da7f14fba640045d0b 100644 (file)
@@ -43,7 +43,7 @@ class Job < ArvadosBase
   end
 
   def stderr_log_query(limit=nil)
-    query = Log.where(object_uuid: self.uuid).order("created_at DESC")
+    query = Log.where(object_uuid: self.uuid).order("created_at DESC").with_count('none')
     query = query.limit(limit) if limit
     query
   end
index b6e0ef17aef886e624f5a9398827091a9d189863..1c14efffa673ea20d94da71a71230bdcc5ffa5cb 100644 (file)
@@ -103,9 +103,10 @@ class PipelineInstance < ArvadosBase
 
   def stderr_log_query(limit=nil)
     query = Log.
-      where(event_type: "stderr",
-            object_uuid: stderr_log_object_uuids).
-      order("id DESC")
+            with_count('none').
+            where(event_type: "stderr",
+                  object_uuid: stderr_log_object_uuids).
+            order("created_at DESC")
     unless limit.nil?
       query = query.limit(limit)
     end
index 42304843d32d3c998235adb523819fb3ae080cdd..b7cc6a0f196951f19472ace07acc37d244500b94 100644 (file)
@@ -309,6 +309,7 @@ class ProxyWorkUnit < WorkUnit
     Log.where(object_uuid: log_object_uuids).
       order("created_at DESC").
       limit(limit).
+      with_count('none').
       select { |log| log.properties[:text].is_a? String }.
       reverse.
       flat_map { |log| log.properties[:text].split("\n") }