From 20e52aee7eb2ebc2e0cc0ec37ab61362b2ce790b Mon Sep 17 00:00:00 2001 From: Lukas Ruge Date: Tue, 3 Jan 2017 08:11:24 +0100 Subject: [PATCH 1/4] making the spaceapi compliant to the new 0.13 specification --- status.rb | 6 +++--- status.yml | 30 ++++++++++++++++-------------- views/index.erb | 6 +++--- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/status.rb b/status.rb index 167fdd5..109338f 100644 --- a/status.rb +++ b/status.rb @@ -153,7 +153,7 @@ def getdata(status, messages) if d != nil and dPrev != nil if d['door_open'] != dPrev['door_open'] start = d['timestamp'] - @lastchange = Time.parse(start + " UTC").to_i + @lastchange = start; break end end @@ -166,8 +166,8 @@ def getdata(status, messages) end json = YAML.load_file('status.yml') - json[:open] = @open - json[:lastchange] = @lastchange + json['state'][:open]= @open + json['state'][:lastchange] = @lastchange content_type 'application/json' jsonp json diff --git a/status.yml b/status.yml index dbb72db..e6b111d 100644 --- a/status.yml +++ b/status.yml @@ -1,21 +1,23 @@ -api: "0.12" +api: "0.13" space: MetaMeute url: https://metameute.de -icon: - open: http://status.metameute.de/images/open.png - closed: http://status.metameute.de/images/closed.png -address: Unversität zu Lübeck, Gebäude 62, Ratzeburger Allee 160, 23562 Lübeck, Germany +state: + icon: + open: http://status.metameute.de/images/open.png + closed: http://status.metameute.de/images/closed.png contact: phone: "+494515005011" - ml: MetaMeute@asta.uni-luebeck.de + email: metameute@asta.uni-luebeck.de + ml: metameute@asta.uni-luebeck.de irc: irc://irc.oftc.net/#Metameute logo: http://status.metameute.de/images/logo.png feeds: - - name: blog - type: application/rss+xml - url: http://blog.metameute.de/feed/ - - name: status - type: application/rss+xml - url: http://status.metameute.de/rss -lat: 53.834372 -lon: 10.702268 + blog: + type: application/rss+xml + url: http://blog.metameute.de/feed/ +issue_report_channels: + - email +location: + lat: 53.834372 + lon: 10.702268 + address: Unversität zu Lübeck, Gebäude 62, Ratzeburger Allee 160, 23562 Lübeck, Germany diff --git a/views/index.erb b/views/index.erb index 5f01bc5..096dd6d 100644 --- a/views/index.erb +++ b/views/index.erb @@ -31,7 +31,7 @@ %> <% if d.has_key? "message" %>
  • - <%= Time.parse(d['timestamp'] + "UTC").localtime.strftime("%Y-%m-%d %H:%M") %> + <%= Time.at(d['timestamp']).localtime.strftime("%Y-%m-%d %H:%M") %> <%= h d['message'] %> <% else %>
  • @@ -40,13 +40,13 @@ <% else %> geschlossen <% end %> - <%= Time.parse(d['timestamp'] + "UTC").localtime.strftime("%Y-%m-%d %H:%M") %> + <%= Time.at(d['timestamp']).localtime.strftime("%Y-%m-%d %H:%M") %> <% end %>
  • <% end %> From e07021ce3a1467857446898ed59d45a67c5c6322 Mon Sep 17 00:00:00 2001 From: Lukas Ruge Date: Tue, 3 Jan 2017 20:09:06 +0100 Subject: [PATCH 2/4] ok, now that I understand the structure of the db better, the changes not related to the space api are no longer relevant --- status.rb | 4 ++-- views/index.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/status.rb b/status.rb index 109338f..50d3671 100644 --- a/status.rb +++ b/status.rb @@ -80,7 +80,7 @@ def getdata(status, messages) (statusS.zip status).each do |d, dPrev| if d != nil and dPrev != nil if d['door_open'] != dPrev['door_open'] - start = d['timestamp'] + " UTC" + start = Time.parse(d['timestamp'] + "UTC").localtime @duration = Time.diff(Time.now(), start, '%h:%m')[:diff] break end @@ -153,7 +153,7 @@ def getdata(status, messages) if d != nil and dPrev != nil if d['door_open'] != dPrev['door_open'] start = d['timestamp'] - @lastchange = start; + @lastchange = Time.parse(start + "UTC").localtime break end end diff --git a/views/index.erb b/views/index.erb index 096dd6d..b052a9e 100644 --- a/views/index.erb +++ b/views/index.erb @@ -31,7 +31,7 @@ %> <% if d.has_key? "message" %>
  • - <%= Time.at(d['timestamp']).localtime.strftime("%Y-%m-%d %H:%M") %> + <%= Time.parse(d['timestamp'] + "UTC").localtime.strftime("%Y-%m-%d %H:%M") %> <%= h d['message'] %> <% else %>
  • @@ -40,7 +40,7 @@ <% else %> geschlossen <% end %> - <%= Time.at(d['timestamp']).localtime.strftime("%Y-%m-%d %H:%M") %> + <%= Time.parse(d['timestamp'] + "UTC").localtime.strftime("%Y-%m-%d %H:%M") %> <% end %>
  • <% end %> From c0b71decd6261d88b37dd219d3de0e83fbfe93a4 Mon Sep 17 00:00:00 2001 From: Lukas Ruge Date: Tue, 3 Jan 2017 20:12:14 +0100 Subject: [PATCH 3/4] no need to add localtime --- status.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/status.rb b/status.rb index 50d3671..414b0bf 100644 --- a/status.rb +++ b/status.rb @@ -80,7 +80,7 @@ def getdata(status, messages) (statusS.zip status).each do |d, dPrev| if d != nil and dPrev != nil if d['door_open'] != dPrev['door_open'] - start = Time.parse(d['timestamp'] + "UTC").localtime + start = Time.parse(d['timestamp'] + "UTC") @duration = Time.diff(Time.now(), start, '%h:%m')[:diff] break end @@ -153,7 +153,7 @@ def getdata(status, messages) if d != nil and dPrev != nil if d['door_open'] != dPrev['door_open'] start = d['timestamp'] - @lastchange = Time.parse(start + "UTC").localtime + @lastchange = Time.parse(start + "UTC") break end end From 0f79540f69790085ff0ab6b1fcc65d1cb71f093f Mon Sep 17 00:00:00 2001 From: Lukas Ruge Date: Tue, 3 Jan 2017 20:27:27 +0100 Subject: [PATCH 4/4] last change must be integer --- status.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/status.rb b/status.rb index 414b0bf..c767a0b 100644 --- a/status.rb +++ b/status.rb @@ -153,7 +153,7 @@ def getdata(status, messages) if d != nil and dPrev != nil if d['door_open'] != dPrev['door_open'] start = d['timestamp'] - @lastchange = Time.parse(start + "UTC") + @lastchange = Time.parse(start + "UTC").localtime.strftime("%s").to_i break end end