diff app/models/tweet.rb @ 146:7ca8aeba1a63

Try tracing where the failures happen
author nanaya <me@nanaya.pro>
date Wed, 13 Dec 2017 08:06:30 +0900
parents c791b6bfeeda
children fd7344643903
line wrap: on
line diff
--- a/app/models/tweet.rb	Wed Dec 13 06:31:07 2017 +0900
+++ b/app/models/tweet.rb	Wed Dec 13 08:06:30 2017 +0900
@@ -20,6 +20,11 @@
       raw = Rails.cache.fetch("timeline:v2:#{@twitter_id}", :expires_in => cache_expires_time) do
         client_try(:user_timeline, @twitter_id, TIMELINE_OPTIONS).tap do |data|
           if data[:result] == :ok
+            if data[:data].any? && data[:data].first.user.id != @twitter_id
+              wrong_user = data[:data].first.user
+              Rails.logger.warn "Wrong timeline data. Requested: #{@twitter_id}, got: #{wrong_user.id} (#{wrong_user.name.printable})"
+            end
+
             data[:data] = data[:data].select do |tweet|
               tweet.retweeted_status.nil? || tweet.user.id != tweet.retweeted_status.user.id
             end.map { |tweet| tweet.to_h }