Skip to content
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

Merged
merged 4 commits into from
Oct 15, 2016

Conversation

fliiiix
Copy link
Member

@fliiiix fliiiix commented Oct 7, 2016

2016-10-07--1475864899_1600x900

Würde dann so aussehen.

Copy link
Member

@rb2k rb2k left a 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/'
Copy link
Member

@rb2k rb2k Oct 7, 2016

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
Copy link
Member

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.
@fliiiix
Copy link
Member Author

fliiiix commented Oct 14, 2016

ping @rb2k schau mal drauf ob das so okey is
habs etwas overengeniert aber es sollte tun und dabei effizient sein

rescue Exception => e
get_xenim_api_data
unless settings.xenim_response.nil?
settings.xenim_response["items"].any?
Copy link
Member

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

Copy link
Member Author

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/'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response, mit e :)

Copy link
Member Author

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)

@rb2k
Copy link
Member

rb2k commented Oct 14, 2016

Schon gut, nur 2 kleine dinger :)

@fliiiix
Copy link
Member Author

fliiiix commented Oct 14, 2016

Sonst noch was, was du gerade siehst?

rescue Exception => e
get_xenim_api_data
if settings.xenim_response
settings.xenim_response.fetch("items", []).any?
Copy link
Member

@rb2k rb2k Oct 14, 2016

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ansonsten nichts weiter auszusetzen)

Copy link
Member Author

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?

Copy link
Member

@rb2k rb2k Oct 15, 2016

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

Copy link
Member Author

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?

@rb2k rb2k merged commit 04c272d into Binaergewitter:master Oct 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants