diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-02-09 16:04:26 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-02-09 16:04:26 +0900 |
commit | e1dd150837cee082a5dd315f327c1ffc50a67ef5 (patch) | |
tree | 99c2ca2592e1d389930a80ddc82ec81511b8b1c4 | |
parent | eaa3dd600282463598eb3015c2dc18b243792e67 (diff) | |
download | aclog-e1dd150837cee082a5dd315f327c1ffc50a67ef5.tar.gz |
fix Tweet.update_from_twitter (follow-up to c3d4489)
-rw-r--r-- | app/models/tweet.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/tweet.rb b/app/models/tweet.rb index ba39f78..742e6f5 100644 --- a/app/models/tweet.rb +++ b/app/models/tweet.rb @@ -95,8 +95,9 @@ class Tweet < ActiveRecord::Base newjsons = sts.reject { |st| currenth[st.id] }.map { |st| st.attrs } Tweet.create_bulk_from_json(newjsons) - exsts = sts.select { |st| currenth[st.id] } - Tweet.where(id: exsts.map(&:id)).zip(exsts) do |tweet, st| + exsts = sts.select { |st| currenth[st.id] }.map { |st| [st.id, st] }.to_h + Tweet.where(id: exsts.keys) do |tweet| + st = exsts[tweet.id] tweet.update(text: extract_entities(st.attrs), source: st.attrs[:source], in_reply_to_id: (tweet.in_reply_to_id || st.attrs[:in_reply_to_status_id]), |