Skip to content

Commit

Permalink
Basic usage report implementation with reports
Browse files Browse the repository at this point in the history
  • Loading branch information
ShimShtein committed Sep 2, 2024
1 parent fd21a88 commit 11066e5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ApplicationRecord < ActiveRecord::Base
end

class Jail < Safemode::Jail
allow :id, :name, :present?
allow :id, :name, :present?, :created_at
end

self.abstract_class = true
Expand Down
2 changes: 1 addition & 1 deletion app/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Domain < ApplicationRecord
prop_group :basic_model_props, ApplicationRecord, meta: { example: 'example.com' }
property :fullname, String, desc: 'User name for this domain, e.g. "Primary domain for our company"'
end
class Jail < Safemode::Jail
class Jail < Jail
allow :id, :name, :fullname
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/smart_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def get_features
property :httpboot_https_port, Integer, desc: 'Returns proxy port for HTTPS boot'
property :httpboot_https_port!, Integer, desc: 'Same as httpboot_https_port, but raises Foreman::Exception if no port is set'
end
class Jail < ::Safemode::Jail
allow :id, :name, :hostname, :httpboot_http_port, :httpboot_https_port, :httpboot_http_port!, :httpboot_https_port!, :url
class Jail < Jail
allow :hostname, :httpboot_http_port, :httpboot_https_port, :httpboot_http_port!, :httpboot_https_port!, :url, :feature_details
end
end
3 changes: 2 additions & 1 deletion app/services/foreman/renderer/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class Configuration
:outofsync_interval,
:default_puppet_environment,
:update_ip_from_built_request,
:lab_features,
]

DEFAULT_ALLOWED_LOADERS = Foreman::Renderer::Scope::Macros::Loaders::LOADERS.map(&:first)
Expand All @@ -138,7 +139,7 @@ def initialize
:allowed_generic_helpers, :allowed_host_helpers, :allowed_loaders

def allowed_helpers
allowed_generic_helpers + allowed_host_helpers + allowed_loaders
allowed_generic_helpers + allowed_host_helpers + allowed_loaders + [:load_any_resource]
end
end
end
Expand Down
8 changes: 7 additions & 1 deletion app/services/foreman/renderer/scope/macros/loaders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ module Loaders
end
end

def load_any_resource(resource:, permission:, search: '', batch: nil)
model = resource.constantize
load_resource(klass: model, search: search, permission: permission, batch: batch)
end

private

# returns a batched relation, use either
Expand All @@ -88,7 +93,8 @@ def load_resource(klass:, search:, permission:, batch: 1_000, includes: nil, lim
base = base.limit(limit) unless limit.nil?
base = base.where(where) unless where.nil?
base = base.select(select) unless select.nil?
base.in_batches(of: batch)
base = base.in_batches(of: batch) unless batch.nil?
base
end
end
end
Expand Down

0 comments on commit 11066e5

Please sign in to comment.