apps/dashboard/app/models/quota.rb
# Get quota objects only for requested user in JSON file(s)
#
# KeyError and JSON::ParserErrors shall be non-fatal errors
Get quota objects only for requested user in JSON file(s)
KeyError and JSON::ParserErrors shall be non-fatal errors
Get quota objects only for requested user in JSON file ( s ) KeyError and JSON :: ParserErrors shall be non - fatal errors
def create_both_quota_types(params)
      params = params.to_h.compact.symbolize_keys
      file_quota = Quota.new(
        type:   params.fetch(:type, :user).to_sym,
        path:   Pathname.new(params.fetch(:path).to_s),
        user:   params.fetch(:user).to_s,    
        resource_type: "file",
        total_usage: params.fetch(:total_file_usage).to_i,
        user_usage: params.fetch(:file_usage, params.fetch(:total_file_usage)).to_i,
        limit: params.fetch(:file_limit).to_i,
        grace: params.fetch(:file_grace, 0).to_i, 
        updated_at: Time.at(params.fetch(:updated_at).to_i),
      )
      block_quota = Quota.new(
        type:   params.fetch(:type, :user).to_sym,
        path:   Pathname.new(params.fetch(:path).to_s),
        user:   params.fetch(:user).to_s,    
        resource_type: "block",
        total_usage: params.fetch(:total_block_usage).to_i,
        user_usage: params.fetch(:block_usage, params.fetch(:total_block_usage)).to_i,
        limit: params.fetch(:block_limit).to_i,
        grace: params.fetch(:block_grace, 0).to_i, 
        updated_at: Time.at(params.fetch(:updated_at).to_i),
      )
      [file_quota, block_quota]
    end
def create_both_quota_types ( params ) params = params . to_h . compact . symbolize_keys file_quota = Quota . new ( type : params . fetch ( :type , :user ) . to_sym , path : Pathname . new ( params . fetch ( :path ) . to_s ) , user : params . fetch ( :user ) . to_s , resource_type : "file" , total_usage : params . fetch ( :total_file_usage ) . to_i , user_usage : params . fetch ( :file_usage , params . fetch ( :total_file_usage ) ) . to_i , limit : params . fetch ( :file_limit ) . to_i , grace : params . fetch ( :file_grace , 0 ) . to_i , updated_at : Time . at ( params . fetch ( :updated_at ) . to_i ) , ) block_quota = Quota . new ( type : params . fetch ( :type , :user ) . to_sym , path : Pathname . new ( params . fetch ( :path ) . to_s ) , user : params . fetch ( :user ) . to_s , resource_type : "block" , total_usage : params . fetch ( :total_block_usage ) . to_i , user_usage : params . fetch ( :block_usage , params . fetch ( :total_block_usage ) ) . to_i , limit : params . fetch ( :block_limit ) . to_i , grace : params . fetch ( :block_grace , 0 ) . to_i , updated_at : Time . at ( params . fetch ( :updated_at ) . to_i ) , ) [ file_quota , block_quota ] end
Get quota objects only for requested user in JSON file(s)
KeyError and JSON::ParserErrors shall be non-fatal errors
Get quota objects only for requested user in JSON file ( s ) KeyError and JSON :: ParserErrors shall be non - fatal errors
# FIXME: Can be integer in rare cases # future functionality # FIXME: Can be integer in rare cases # future functionality
params