class Wms::Widget::Wifissid::Main
This widget will read the wifi record from the event. It will then find the list of distinct wifi ssid getting the unique wifi names..
Input: a list of wifi events. Output: analytics
{:device_id => "123456789", :widget_id = > '1', :user_id => '1', :timestamp => "2013-11-06 00:00:00 -0800", :wifi_ssid_list => ["Cow", "Cat", "Fox"] } {:device_id => "123456789", :widget_id = > '1', :user_id => '1', :timestamp => "2013-11-06 00:01:00 -0800", :wifi_ssid_list => ["Dog", "Whale", "Giraffe"] } {:device_id => "123456789", :widget_id = > '1', :user_id => '1', :timestamp => "2013-11-06 00:02:00 -0800", :wifi_ssid_list => ["Fox", "Elephant", "Bird"] } ...
Run the widget Open rails console >Widget.load_widgets >widget.run_widgets
Enjoy!
Attributes
widget[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/wms/widget/wifissid/main.rb, line 38 def initialize super @logger.debug "Init widget [#{self.class.name}]" end
Public Instance Methods
register(options={})
click to toggle source
@override
# File lib/wms/widget/wifissid/main.rb, line 44 def register(options={}) @widget = options[:widget] @begin = options[:begin] @end = options[:end] end
run()
click to toggle source
@override
# File lib/wms/widget/wifissid/main.rb, line 51 def run # Call api @logger.debug "Running widget [#{self.class.name}]" # Insert your code here options = { #:device_id => "12345678", :type => "wifi_accesspoint_info", # :begin => @begin, # :end => @end } @events = get_events(options) (@events.count.to_i).times do |i| wifi_arr = Set.new [] cur = @events[i] wifi_lst = cur["list"] wifi_lst.each do |n| wifi_arr.add(n["SSID"]) end analytic = { :device_id => cur["device_id"], :widget_id => @widget.id, :user_id => @widget.user.id, :timestamp => Time.now, :wifi_ssid_list => wifi_arr } save_analytics(analytic) end end