comparison app/models/tweet.rb @ 144:1925b08153dc

Record 404s
author nanaya <me@nanaya.pro>
date Wed, 13 Dec 2017 06:10:13 +0900
parents 8a858aec1905
children c791b6bfeeda
comparison
equal deleted inserted replaced
143:8a858aec1905 144:1925b08153dc
28 if initial_config_id == client_config_id 28 if initial_config_id == client_config_id
29 raise 29 raise
30 else 30 else
31 retry 31 retry
32 end 32 end
33 rescue Twitter::Error::NotFound
34 data = { :result => :not_found }
33 end 35 end
34 36
35 timeline.select do |tweet| 37 data || {
36 tweet.retweeted_status.nil? || tweet.user.id != tweet.retweeted_status.user.id 38 :result => :ok,
37 end.map do |tweet| 39 :timeline => timeline.select do |tweet|
38 # Fails when there's Twitter::NullObject initiated somewhere in previous select 40 tweet.retweeted_status.nil? || tweet.user.id != tweet.retweeted_status.user.id
39 # Reference: https://github.com/sferik/twitter/issues/892 41 end.map do |tweet|
40 tweet.to_h 42 # Fails when there's Twitter::NullObject initiated somewhere in previous select
43 # Reference: https://github.com/sferik/twitter/issues/892
44 tweet.to_h
45 end,
46 }
47 end.tap do |data|
48 raise Twitter::Error::NotFound if data[:result] == :not_found
49
50 data[:timeline_parsed] = data[:timeline].map do |tweet_hash|
51 Twitter::Tweet.new(tweet_hash)
41 end 52 end
42 end.map do |tweet_hash| 53 end[:timeline_parsed]
43 Twitter::Tweet.new(tweet_hash)
44 end
45 end 54 end
46 55
47 def user 56 def user
48 @user ||= 57 @user ||=
49 if timeline.any? 58 if timeline.any?