Cisco Meraki18というWifiのAPを今回使っています
このAPからwifi proveした情報が1〜3分に1回送られるようになってます
そのときに送るデータは下記のようになってます
{ "apMac": <string>, "apTags": [<string, ...], "apFloors": [<string>, ...], "observations": [ { "clientMac": <string>, "ipv4": <string>, "ipv6": <string>, "seenTime": <string>, "seenEpoch": <integer>, "ssid": <string>, "rssi": <integer>, "manufacturer": <string>, "os": <string>, "location": { "lat": <decimal>, "lng": <decimal>, "unc": <decimal>, "x": [<decimal>, ...], "y": [<decimal>, ...] }, },... ] }
このデータの中で"seenTime"の時間が9時間前となってしまっています。
これはどうすればいいでしょうか?
データはJson形式で送られてきます
データの受け取り、テーブルに保存するまで
ruby
1#app/controllers/events_controller.rb 2def create 3 @event = Event.new(data: params[:data].to_s) 4 respond_to do |format| 5 if @event.save 6 format.html { redirect_to @event, notice: 'Event was successfully created.' } 7 format.json { render :show, status: :created, location: @event } 8 else 9 format.html { render :new } 10 format.json { render json: @event.errors, status: :unprocessable_entity } 11 end 12 end 13end 14 15データが送られてきたときの形 16Processing by EventsController#create as HTML 17 Parameters: {"version"=>"2.0", "secret"=>"xxxxxxx", "type"=>"DevicesSeen", 18"data"=>{"apMac"=>"00:18:0a:bb:cc:dd", "apFloors"=>[], "apTags"=>["", "dev", "recently-added", ""], 19 "observations"=>[{"ipv4"=>nil, "location"=>{"lat"=>37.53465, "lng"=>121.41352423000004, 20 "unc"=>49.0, "x"=>[], "y"=>[]}, "seenTime"=>"2018-08-16T08:52:48Z", "ssid"=>nil, "os"=>nil, 21 "clientMac"=>"24:31:4:33:22:11", "seenEpoch"=>1534409568, "rssi"=>5, "ipv6"=>nil, 22 "manufacturer"=>"SHARP"}, {"ipv4"=>nil, "location"............."manufacturer"=>"Intel"}]}}} 23 24 25テーブル保存時のデータ 26{"apMac"=>"00:18:44:33:22:11", "apFloors"=>[], "apTags"=>["", "dev", "recently-added", ""], 27 "observations"=>[{"ipv4"=>nil, "location"=>{"lat"=>37.5, "lng"=>121.413230000004, 28 "unc"=>49.0, "x"=>[], "y"=>[]}, "seenTime"=>"2018-08-16T08:10:54Z", "ssid"=>nil, "os"=>nil, 29"clientMac"=>"da:a4:ca:53:bb:aa", "seenEpoch"=>1534407054, "rssi"=>8, "ipv6"=>nil, "manufacturer"=>"Apple"}, 30 {"ipv4"=>nil, "location".....]}
###試したこと
Merakiダッシュボードでタイムゾーンのを東京に変更
mysql> show variables like '%time_zone%';
+------------------+------------+
| Variable_name | Value |
+------------------+------------+
| system_time_zone | JST |
| time_zone | Asia/Tokyo |
+------------------+------------+
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/16 08:16
2018/08/16 08:25
2018/08/16 08:36
2018/08/16 08:42
2018/08/16 08:58
2018/08/16 09:05 編集
2018/08/16 09:12 編集
2018/08/16 09:08
2018/08/16 09:11
2018/08/16 09:11
2018/08/16 09:21
2018/08/16 14:28