Sha256: eebdf46aadfa75941170c2d4f8162bb9c68b8fdbbe346ddc2a0e01a41d448c4b

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require './auth'
class HistoricsApi < DataSiftExample
  def initialize
    super
    run_historics
  end

  def run_historics
    begin
      stream   = @datasift.compile 'interaction.content contains "datasift"'
      hash     = stream[:data][:hash]
      start    = Time.now.to_i - 7200
      end_time = start + 3600

      puts 'Check the data coverage for the last two hours'
      puts @datasift.historics.status(start, end_time)

      puts 'Preparing'
      #prepare a historics to start from two hours ago and run for 1 hour using twitter as a data source and using only a 10% sample
      historics = @datasift.historics.prepare(hash, start, end_time, 'My ruby historics')
      puts historics

      id = historics[:data][:id]

      puts 'Creating push subscription for historics'
      puts create_push(id, true)

      puts "Starting historics #{id}"
      puts @datasift.historics.start id

      puts 'Updating historics'
      puts @datasift.historics.update(id, 'The new name of my historics')

      puts 'Get info for the historics'
      puts @datasift.historics.get_by_id id

      puts 'Getting info for all my historics'
      puts @datasift.historics.get

      puts 'Stopping historics'
      puts @datasift.historics.stop id

      puts 'Deleting historics'
      puts @datasift.historics.delete id
    rescue DataSiftError => dse
      puts dse.message
    end
  end
end
HistoricsApi.new

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datasift-3.0.0.beta4 examples/historics_eg.rb
datasift-3.0.0.beta2 examples/historics_eg.rb
datasift-3.0.0.beta examples/historics_eg.rb