lib/jss/api_object/extension_attribute/computer_extension_attribute.rb
# Return an Array of Hashes showing the history of reported values for this EA on one computer.
#
# Each hash contains these 2 keys:
# * :value - String, Integer, or Time, depending on @data_type
# * :timestamp  - Time
#
# This method requires a MySQL database connection established via JSS::DB_CNX.connect
#
# @see JSS::DBConnection
#
# @param computer[Integer,String]  the id or name of the Computer.
#
# @return [Array<Hash{:timestamp=>Time,:value=>String,Integer,Time}>]
#
Return an Array of Hashes showing the history of reported values for this EA on one computer.
Each hash contains these 2 keys:
:value - String, Integer, or Time, depending on @data_type
:timestamp  - Time

This method requires a MySQL database connection established via JSS::DB_CNX.connect
Return an Array of Hashes showing the history of reported values for this EA on one computer . Each hash contains these 2 keys : : value - String Integer or Time depending on @data_type : timestamp - Time This method requires a MySQL database connection established via JSS :: DB_CNX . connect
def history(computer)
      raise JSS::NoSuchItemError, "EA Not In JSS! Use #create to create this #{RSRC_OBJECT_KEY}." unless @in_jss
      raise JSS::InvalidConnectionError, "Database connection required for 'history' query." unless JSS::DB_CNX.connected?
      computer_id = JSS::Computer.valid_id computer, api: @api
      raise JSS::NoSuchItemError, "No computer found matching '#{computer}'" unless computer_id
      the_query = <<-END_Q
      SELECT eav.value_on_client AS value, r.date_entered_epoch AS timestamp_epoch
      FROM extension_attribute_values eav JOIN reports r ON eav.report_id = r.report_id
      WHERE r.computer_id = #{computer_id}
        AND eav.extension_attribute_id = #{@id}
      ORDER BY timestamp_epoch
      END_Q
      qrez = JSS::DB_CNX.db.query the_query
      history = []
      qrez.each_hash do |entry|
        value =
          case @data_type
          when 'String' then entry['value']
          when 'Integer' then entry['value'].to_i
          when 'Date' then JSS.parse_datetime(entry['value'])
          end 
        newhash = { value: value, timestamp: JSS.epoch_to_time(entry['timestamp_epoch']) }
        history << newhash
      end 
      history
    end
def history ( computer ) raise JSS :: NoSuchItemError , "EA Not In JSS! Use #create to create this #{RSRC_OBJECT_KEY}." unless @in_jss raise JSS :: InvalidConnectionError , "Database connection required for 'history' query." unless JSS :: DB_CNX . connected? computer_id = JSS :: Computer . valid_id computer , api : @api raise JSS :: NoSuchItemError , "No computer found matching '#{computer}'" unless computer_id the_query = <<-END_Q 
      SELECT eav.value_on_client AS value, r.date_entered_epoch AS timestamp_epoch
      FROM extension_attribute_values eav JOIN reports r ON eav.report_id = r.report_id
      WHERE r.computer_id =  #{ computer_id } 
        AND eav.extension_attribute_id =  #{ @id } 
      ORDER BY timestamp_epoch
       END_Q qrez = JSS :: DB_CNX . db . query the_query history = [ ] qrez . each_hash do | entry | value = case @data_type when 'String' then entry [ 'value' ] when 'Integer' then entry [ 'value' ] . to_i when 'Date' then JSS . parse_datetime ( entry [ 'value' ] ) end newhash = { value : value , timestamp : JSS . epoch_to_time ( entry [ 'timestamp_epoch' ] ) } history << newhash end history end
Return an Array of Hashes showing the history of reported values for this EA on one computer.
Return an Array of Hashes showing the history of reported values for this EA on one computer .
# case # each hash
None
Array<Hash{:timestamp=>Time,:value=>String,Integer,Time}>
computer
the id or name of the Computer.
the id or name of the Computer .
see
None