+ @proxied.is_a?(ContainerRequest) && state_label.in?(["Queued", "Locked", "Running"]) && priority > 0
+ end
+
+ def container_uuid
+ get(:container_uuid)
+ end
+
+ # For the following properties, use value from the @container if exists
+ # This applies to a ContainerRequest with container_uuid
+
+ def started_at
+ t = get_combined(:started_at)
+ t = Time.parse(t) if (t.is_a? String)
+ t
+ end
+
+ def modified_at
+ t = get_combined(:modified_at)
+ t = Time.parse(t) if (t.is_a? String)
+ t
+ end
+
+ def finished_at
+ t = get_combined(:finished_at)
+ t = Time.parse(t) if (t.is_a? String)
+ t
+ end
+
+ def state_label
+ get_combined(:state)
+ end
+
+ def docker_image
+ get_combined(:container_image)
+ end
+
+ def runtime_constraints
+ get_combined(:runtime_constraints)
+ end
+
+ def priority
+ get_combined(:priority)
+ end
+
+ def log_collection
+ get_combined(:log)
+ end
+
+ def outputs
+ items = []
+ items << get_combined(:output) if get_combined(:output)
+ items
+ end
+
+ def command
+ get_combined(:command)
+ end
+
+ def cwd
+ get_combined(:cwd)
+ end
+
+ def environment
+ env = get_combined(:environment)
+ env = nil if env.andand.empty?
+ env
+ end
+
+ def mounts
+ mnt = get_combined(:mounts)
+ mnt = nil if mnt.andand.empty?
+ mnt
+ end
+
+ def output_path
+ get_combined(:output_path)
+ end
+
+ def log_object_uuids
+ [get_combined(:uuid), get(:uuid)].uniq
+ end
+
+ def live_log_lines(limit=2000)
+ event_types = ["stdout", "stderr", "arv-mount", "crunch-run"]
+ log_lines = Log.where(event_type: event_types, object_uuid: log_object_uuids).order("id DESC").limit(limit)
+ log_lines.results.reverse.
+ flat_map { |log| log.properties[:text].split("\n") rescue [] }
+ end
+
+ def render_log
+ collection = Collection.find(log_collection) rescue nil
+ if collection
+ return {log: collection, partial: 'collections/show_files', locals: {object: collection, no_checkboxes: true}}
+ end
+ end
+
+ def template_uuid
+ properties = get(:properties)
+ if properties
+ properties[:template_uuid]
+ end
+ end
+
+ # End combined propeties
+
+ protected
+ def get_combined key
+ get(key, @container) || get(key, @proxied)