diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-06-17 23:54:49 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-06-17 23:54:49 +0900 |
commit | 2cb61dac88ebffc32ea7093786e2b35ea2602c77 (patch) | |
tree | 4793da3ef6455f2cf02d1199b53523042083fff3 | |
parent | a90f93328f7813df74be2e9ec52f9f0e9866aca4 (diff) | |
parent | 9285be68f1d349383d05493b86a3326c0e5630ef (diff) | |
download | aclog-2cb61dac88ebffc32ea7093786e2b35ea2602c77.tar.gz |
Merge branch 'master' into collector-proxy
-rw-r--r-- | app/models/worker_manager.rb | 2 | ||||
-rw-r--r-- | app/views/about/status.html.haml | 2 | ||||
-rw-r--r-- | app/views/tweets/_tweets_template.html.haml | 58 | ||||
-rw-r--r-- | worker_node/lib/user_connection.rb | 33 |
4 files changed, 47 insertions, 48 deletions
diff --git a/app/models/worker_manager.rb b/app/models/worker_manager.rb index 25c4884..6eac369 100644 --- a/app/models/worker_manager.rb +++ b/app/models/worker_manager.rb @@ -4,7 +4,7 @@ class WorkerManager class << self def alive? !!client - rescue Aclog + rescue Aclog::Exceptions::WorkerConnectionError false end diff --git a/app/views/about/status.html.haml b/app/views/about/status.html.haml index 5bcb2ae..d199625 100644 --- a/app/views/about/status.html.haml +++ b/app/views/about/status.html.haml @@ -26,4 +26,4 @@ %td - - else .alert.alert-danger - %strong Couldn't communicate with the collector service. + %strong The collector service is down. diff --git a/app/views/tweets/_tweets_template.html.haml b/app/views/tweets/_tweets_template.html.haml index 54a6eaa..2a9910b 100644 --- a/app/views/tweets/_tweets_template.html.haml +++ b/app/views/tweets/_tweets_template.html.haml @@ -25,38 +25,32 @@ %li< %a.aclogicon.aclogicon-reply{href: "https://twitter.com/intent/tweet?in_reply_to={{id_str}}", title: "返信", data: {"v-on" => "click: openIntent"}} .status-responses - %template{data: {"v-if" => "favorites_count > 0"}} - %dl - %dt - %a.expand-responses-button{href: "#", title: "すべて見る", data: {"v-on" => "click: toggleExpandFavorites(this, $event)"}}< - %span> {{favorites_count}} - Favs - %dd{data: {"v-class" => "collapsed: !expandFavorites"}} - %ul{class: "status-responses-favorites"} - %li{data: {"v-if" => "loading"}} - %img.loading-image{src: image_path("loading.gif")} - %li{data: {"v-repeat" => "favorites"}}< - %template{data: {"v-if" => "allowed"}} - %a{href: user_path("dummy").sub("dummy", "{{screen_name}}"), title: "{{name | removeInvalidCharacters}} (@{{screen_name}})"}< - %img.twitter-icon{src: "{{profile_image_url}}", alt: "@{{screen_name}}", data: {"v-on" => "error: failProfileImage"}} - %template{data: {"v-if" => "!allowed"}} - %img{src: image_path("profile_image_protected.png"), alt: "protected user"} - %template{data: {"v-if" => "retweets_count > 0"}} - %dl - %dt - %a.expand-responses-button{href: "#", title: "すべて見る", data: {"v-on" => "click: toggleExpandRetweets(this, $event)"}}< - %span> {{retweets_count}} - RTs - %dd{data: {"v-class" => "collapsed: !expandRetweets"}} - %ul{class: "status-responses-retweets"} - %li{data: {"v-if" => "loading"}} - %img.loading-image{src: image_path("loading.gif")} - %li{data: {"v-repeat" => "retweets"}}< - %template{data: {"v-if" => "allowed"}} - %a{href: user_path("dummy").sub("dummy", "{{screen_name}}"), title: "{{name | removeInvalidCharacters}} (@{{screen_name}})"}< - %img.twitter-icon{src: "{{profile_image_url}}", alt: "@{{screen_name}}", data: {"v-on" => "error: failProfileImage"}} - %template{data: {"v-if" => "!allowed"}} - %img{src: image_path("profile_image_protected.png"), alt: "protected user"} + %dl{data: {"v-if" => "favorites_count > 0"}} + %dt + %a.expand-responses-button{href: "#", title: "すべて見る", data: {"v-on" => "click: toggleExpandFavorites(this, $event)"}}< + %span> {{favorites_count}} + Favs + %dd{data: {"v-class" => "collapsed: !expandFavorites"}} + %ul{class: "status-responses-favorites"} + %li{data: {"v-if" => "loading"}} + %img.loading-image{src: image_path("loading.gif")} + %li{data: {"v-repeat" => "favorites"}}< + %a{data: {"v-if" => "allowed"}, href: user_path("dummy").sub("dummy", "{{screen_name}}"), title: "{{name | removeInvalidCharacters}} (@{{screen_name}})"}< + %img.twitter-icon{src: "{{profile_image_url}}", alt: "@{{screen_name}}", data: {"v-on" => "error: failProfileImage"}} + %img{data: {"v-if" => "!allowed"}, src: image_path("profile_image_protected.png"), alt: "protected user"} + %dl{data: {"v-if" => "retweets_count > 0"}} + %dt + %a.expand-responses-button{href: "#", title: "すべて見る", data: {"v-on" => "click: toggleExpandRetweets(this, $event)"}}< + %span> {{retweets_count}} + RTs + %dd{data: {"v-class" => "collapsed: !expandRetweets"}} + %ul{class: "status-responses-retweets"} + %li{data: {"v-if" => "loading"}} + %img.loading-image{src: image_path("loading.gif")} + %li{data: {"v-repeat" => "retweets"}}< + %a{data: {"v-if" => "allowed"}, href: user_path("dummy").sub("dummy", "{{screen_name}}"), title: "{{name | removeInvalidCharacters}} (@{{screen_name}})"}< + %img.twitter-icon{src: "{{profile_image_url}}", alt: "@{{screen_name}}", data: {"v-on" => "error: failProfileImage"}} + %img{data: {"v-if" => "!allowed"}, src: image_path("profile_image_protected.png"), alt: "protected user"} %template{data: {"v-if" => "!allowed"}} .status-tweet .status-user diff --git a/worker_node/lib/user_connection.rb b/worker_node/lib/user_connection.rb index 1842ff8..83c030a 100644 --- a/worker_node/lib/user_connection.rb +++ b/worker_node/lib/user_connection.rb @@ -84,25 +84,28 @@ class UserConnection end end - def on_user(json) + def on_user(json, timestamp = nil) + timestamp ||= json[:timestamp_ms] log(:debug, "User: @#{json[:screen_name]} (#{json[:id]})") EventChannel << { event: :user, identifier: "user-#{json[:id]}-#{json[:profile_image_url_https]}", data: compact_user(json) } end - def on_tweet(json) + def on_tweet(json, timestamp = nil) + timestamp ||= json[:timestamp_ms] log(:debug, "Tweet: #{json[:user][:id]} => #{json[:id]}") - on_user(json[:user]) + on_user(json[:user], timestamp) EventChannel << { event: :tweet, - identifier: "tweet-#{json[:id]}##{json[:timestamp_ms]}-#{json[:favorite_count]}-#{json[:retweet_count]}", + identifier: "tweet-#{json[:id]}##{timestamp}-#{json[:favorite_count]}-#{json[:retweet_count]}", data: compact_tweet(json) } end - def on_retweet(json) + def on_retweet(json, timestamp = nil) + timestamp ||= json[:timestamp_ms] log(:debug, "Retweet: #{json[:user][:id]} => #{json[:retweeted_status][:id]}") - on_user(json[:user]) - on_tweet(json[:retweeted_status]) + on_user(json[:user], timestamp) + on_tweet(json[:retweeted_status], timestamp) EventChannel << { event: :retweet, identifier: "retweet-#{json[:id]}", data: { id: json[:id], @@ -111,20 +114,22 @@ class UserConnection user: { id: json[:retweeted_status][:user][:id] } } } } end - def on_event_tweet(json) + def on_event_tweet(json, timestamp = nil) + timestamp ||= json[:timestamp_ms] || (Time.parse(json[:created_at]).to_i * 1000).to_s rescue nil log(:debug, "Event: #{json[:event]}: #{json[:source][:screen_name]} => #{json[:target][:screen_name]}/#{json[:target_object][:id]}") - on_user(json[:source]) - on_user(json[:target]) - on_tweet(json[:target_object]) + on_user(json[:source], timestamp) + on_user(json[:target], timestamp) + on_tweet(json[:target_object], timestamp) EventChannel << { event: json[:event].to_sym, - identifier: "#{json[:event]}-#{json[:timestamp_ms]}-#{json[:source][:id]}-#{json[:target_object][:id]}", - data: { timestamp_ms: json[:timestamp_ms], + identifier: "#{json[:event]}-#{timestamp}-#{json[:source][:id]}-#{json[:target_object][:id]}", + data: { timestamp_ms: timestamp, source: { id: json[:source][:id] }, target: { id: json[:target][:id] }, target_object: { id: json[:target_object][:id] } } } end - def on_delete(json) + def on_delete(json, timestamp = nil) + timestamp ||= json[:timestamp_ms] log(:debug, "Delete: #{json[:delete][:status]}") EventChannel << { event: :delete, identifier: "delete-#{json[:delete][:status][:id]}", |