-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vorschlag wie man den BUG #125 fixen könnte #190
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sieht gut aus, nur 2 kleine dinge.
Ich nehm an es würde dann eben ein extra HTTP request stattfindne wenn wir senden.
connection.open_timeout = 5 | ||
|
||
#get data | ||
respons = connection.get '/live/binaergewitter/json/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response oder resp :)
|
||
#get data | ||
respons = connection.get '/live/binaergewitter/json/' | ||
data = respons.body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pack es direkt in den JSON parse, dann brauchst keine extra variable
Now only every 15 sec the xenim api will provide the response. For every other request a simple object cache will be used. Meaning there is only one xenim API request every 15 sec.
ping @rb2k schau mal drauf ob das so okey is |
rescue Exception => e | ||
get_xenim_api_data | ||
unless settings.xenim_response.nil? | ||
settings.xenim_response["items"].any? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if settings.xenim_response
return settings.xenim_response.fetch("items", []).empty?
else
return false
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Em auch mit fetch
müsste das dann any?
sein und die returns sind nett aber überflüssig 😃
connection.open_timeout = 5 | ||
|
||
#get data | ||
respons = connection.get '/live/binaergewitter/json/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response, mit e :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
einmal ist keinmal, zwei mal ist ämm autocorrection (*Dummheit)
Schon gut, nur 2 kleine dinger :) |
Sonst noch was, was du gerade siehst? |
rescue Exception => e | ||
get_xenim_api_data | ||
if settings.xenim_response | ||
settings.xenim_response.fetch("items", []).any? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ich denke das ist eher empty? statt any?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ansonsten nichts weiter auszusetzen)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_live? soll ja true zurück geben wenn der Podcast live ist einverstanden?
Wenn man jetzt aber empty nimmt ist es ja false wenn der key items
exisitert
2.3.1 :001 > obj = {"description"=>"Eine wöchentliche Geek-Talk-Runde mit 3-6 Leuten, die meistens aus dem Hackerspace in Stuttgart (Shackspace) sendet. Wir reden über die News der letzten Woche und quatschen vornehmlich über Entwicklung, Web und Mobilezeugs sowie Open Source. Talk-Show rund um IT, Entwicklung und Open Source", "feed_url"=>"http://feeds.streams.xenim.de/live/binaergewitter/json/", "title"=>"xsn Archive for Binärgewitter", "items"=>[{"website"=>"http://www.die-quasselstrippen.de/", "begin"=>"2014-01-18T11:02:39.084+01:00", "end"=>"2014-01-18T13:00:00+01:00", "description"=>"Der pseudointellektuelle, moralinsaure Podcast mit erhobenem Zeigefinger und irrealem Parasymbolismus.", "pubdate"=>"2014-01-18T11:29:07.533+01:00", "title"=>"Die Quasselstrippen", "author_name"=>"Quasselstrippen", "listener"=>"12", "link"=>"http://streams.xenim.de/quasselstrippen/QS061/", "unique_id"=>"quasselstrippen-QS061", "streams"=>["http://streams.xenim.de/quasselstrippen.mp3"], "channel"=>"quasselstrippen", "icon"=>"http://media.streams.xenim.de/show-icons/QS4_4.png"}], "language"=>"de-de", "link"=>"http://streams.xenim.de/binaergewitter/", "id"=>"http://streams.xenim.de/binaergewitter/", "icon"=>"http://media.streams.xenim.de/show-icons/binaergewitter_logo.png"}
=> {"description"=>"Eine wöchentliche Geek-Talk-Runde mit 3-6 Leuten, die meistens aus dem Hackerspace in Stuttgart (Shackspace) sendet. Wir reden über die News der letzten Woche und quatschen vornehmlich über Entwicklung, Web und Mobilezeugs sowie Open Source. Talk-Show rund um IT, Entwicklung und Open Source", "feed_url"=>"http://feeds.streams.xenim.de/live/binaergewitter/json/", "title"=>"xsn Archive for Binärgewitter", "items"=>[{"website"=>"http://www.die-quasselstrippen.de/", "begin"=>"2014-01-18T11:02:39.084+01:00", "end"=>"2014-01-18T13:00:00+01:00", "description"=>"Der pseudointellektuelle, moralinsaure Podcast mit erhobenem Zeigefinger und irrealem Parasymbolismus.", "pubdate"=>"2014-01-18T11:29:07.533+01:00", "title"=>"Die Quasselstrippen", "author_name"=>"Quasselstrippen", "listener"=>"12", "link"=>"http://streams.xenim.de/quasselstrippen/QS061/", "unique_id"=>"quasselstrippen-QS061", "streams"=>["http://streams.xenim.de/quasselstrippen.mp3"], "channel"=>"quasselstrippen", "icon"=>"http://media.streams.xenim.de/show-icons/QS4_4.png"}], "language"=>"de-de", "link"=>"http://streams.xenim.de/binaergewitter/", "id"=>"http://streams.xenim.de/binaergewitter/", "icon"=>"http://media.streams.xenim.de/show-icons/binaergewitter_logo.png"}
2.3.1 :002 > obj.fetch("items", []).empty?
=> false
Also entweder ist es halt nicht ! .empty? oder halt etwas schöner einfach any?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok ok :)
Ich hatte nur noch nie jemand gesehen der .any? ohne block argument benutzt hat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ist eigentlich auch mit block argument 😉
If the block is not given, Ruby adds an implicit block of { |obj| obj } that will cause any? to return true if at least one of the collection members is not false or nil.
Ich finde es halt lesbarer als die Kombination aus ! und .empty?
Würde dann so aussehen.