aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorre4k <re4k@re4k.info>2013-04-13 16:34:24 +0900
committerre4k <re4k@re4k.info>2013-04-13 16:34:24 +0900
commit84e85f40ebe77e7cfad22b7b53b2c77ad8043627 (patch)
tree27d2975600d9d14146034134fdc8f86af155317e
parent62cb571ea3773039c8a61859fe0bbc1e74c94575 (diff)
downloadaclog-84e85f40ebe77e7cfad22b7b53b2c77ad8043627.tar.gz
fix typo, change charset to utf8mb4(MySQL), fix importing
-rw-r--r--Gemfile4
-rw-r--r--Gemfile.lock33
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--app/models/account.rb2
-rw-r--r--app/models/favorite.rb2
-rw-r--r--app/views/main/api.html.haml21
-rw-r--r--app/views/shared/_sidebar_users.html.haml2
-rw-r--r--client/worker.rb3
-rw-r--r--config/unicorn.rb2
-rw-r--r--db/migrate/20130413042256_my_sql_change_charset.rb21
-rw-r--r--db/schema.rb16
-rw-r--r--spec/models/tweet_spec.rb2
12 files changed, 64 insertions, 48 deletions
diff --git a/Gemfile b/Gemfile
index 32e3cea..834589e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,7 +2,7 @@ ruby '1.9.3'
source 'https://rubygems.org'
gem 'rails', '4.0.0.beta1'
-gem 'mysql2'
+gem 'mysql2', "> 0.3.12b"
gem 'dalli'
gem 'counter_culture'
@@ -16,7 +16,7 @@ gem 'msgpack'
gem 'em-work_queue'
gem 'twitter'
-gem 'omniauth-twitter', :github => "re4k/omniauth-twitter"
+gem 'omniauth-twitter', :github => "rhenium/omniauth-twitter"
gem 'kaminari'
gem 'haml-rails'
diff --git a/Gemfile.lock b/Gemfile.lock
index ecc7377..39938f2 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,5 +1,5 @@
GIT
- remote: git://github.com/re4k/omniauth-twitter.git
+ remote: git://github.com/rhenium/omniauth-twitter.git
revision: 313df7eb05e78477cf3eb06bced3c9b64957840f
specs:
omniauth-twitter (0.0.14)
@@ -36,7 +36,7 @@ GEM
after_commit_action (0.1.3)
activerecord (>= 3.0.0)
arel (4.0.0.beta2)
- atomic (1.0.2)
+ atomic (1.1.7)
bootstrap-sass (2.3.1.0)
sass (~> 3.2)
builder (3.1.4)
@@ -52,7 +52,7 @@ GEM
daemon-spawn (0.4.2)
daemons (1.1.9)
dalli (2.6.2)
- diff-lcs (1.2.2)
+ diff-lcs (1.2.3)
em-work_queue (0.0.1)
eventmachine
erubis (2.7.0)
@@ -66,18 +66,19 @@ GEM
railties (>= 3.0.0)
faraday (0.8.7)
multipart-post (~> 1.1)
- haml (4.0.1)
+ haml (4.0.2)
tilt
haml-rails (0.4)
actionpack (>= 3.1, < 4.1)
activesupport (>= 3.1, < 4.1)
haml (>= 3.1, < 4.1)
railties (>= 3.1, < 4.1)
- hashie (1.2.0)
- hike (1.2.1)
+ hashie (2.0.3)
+ hike (1.2.2)
i18n (0.6.4)
- jbuilder (1.2.0)
+ jbuilder (1.3.0)
activesupport (>= 3.0.0)
+ multi_json (>= 1.2.0)
jquery-rails (2.2.1)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
@@ -91,14 +92,14 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.22)
- minitest (4.7.0)
+ minitest (4.7.1)
msgpack (0.5.4)
multi_json (1.7.2)
multipart-post (1.2.0)
- mysql2 (0.3.11)
+ mysql2 (0.3.12b6)
oauth (0.4.7)
- omniauth (1.1.3)
- hashie (~> 1.2)
+ omniauth (1.1.4)
+ hashie (>= 1.2, < 3)
rack
omniauth-oauth (1.0.1)
oauth
@@ -134,7 +135,7 @@ GEM
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
- rspec-mocks (2.13.0)
+ rspec-mocks (2.13.1)
rspec-rails (2.13.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
@@ -149,7 +150,7 @@ GEM
sprockets-rails (~> 2.0.0.rc0)
tilt (~> 1.3)
simple_oauth (0.2.0)
- sprockets (2.9.0)
+ sprockets (2.9.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
@@ -165,7 +166,7 @@ GEM
thor (0.18.1)
thread_safe (0.1.0)
atomic
- tilt (1.3.6)
+ tilt (1.3.7)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
@@ -174,7 +175,7 @@ GEM
multi_json (~> 1.0)
simple_oauth (~> 0.2)
tzinfo (0.3.37)
- uglifier (1.3.0)
+ uglifier (2.0.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
unicorn (4.6.2)
@@ -199,7 +200,7 @@ DEPENDENCIES
jquery-rails
kaminari
msgpack
- mysql2
+ mysql2 (> 0.3.12b)
omniauth-twitter!
rails (= 4.0.0.beta1)
rails_config
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 50d1761..4973e08 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -56,9 +56,9 @@ class ApplicationController < ActionController::Base
def count; get_int(params[:count], 10){|i| (1..100) === i} end
- def max_id; get_int(params[:max_id], nil) end
+ def max_id; get_int(params[:max_id], nil){|i| i >= 0} end
- def since_id; get_int(params[:since_id], nil) end
+ def since_id; get_int(params[:since_id], nil){|i| i >= 0} end
def order
case params[:order]
diff --git a/app/models/account.rb b/app/models/account.rb
index 37eb927..2eb9032 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -39,7 +39,7 @@ class Account < ActiveRecord::Base
end
# rts 回収・RTのステータスIDを取得する必要がある
- client.retweets(id).each do |status|
+ client.retweets(id, :count => 100).each do |status|
Retweet.from_tweet_object(status)
end
end
diff --git a/app/models/favorite.rb b/app/models/favorite.rb
index a83a4d3..f1fc836 100644
--- a/app/models/favorite.rb
+++ b/app/models/favorite.rb
@@ -31,7 +31,7 @@ class Favorite < ActiveRecord::Base
def self.from_tweet_object(tweet_object)
if tweet_object.favoriters.is_a? Array
- tweet_object.favoriters.map do |uid|
+ tweet_object.favoriters.reverse.map do |uid|
from_hash(:user_id => uid, :tweet_id => tweet_object.id)
end
end
diff --git a/app/views/main/api.html.haml b/app/views/main/api.html.haml
index 15e9da5..b24834d 100644
--- a/app/views/main/api.html.haml
+++ b/app/views/main/api.html.haml
@@ -12,7 +12,7 @@
%dd /users/{best|timeline|discovered}.json
%dt 他ユーザーが関係してくるもの
%dd /users/{favorited_by|retweeted_by|given_favorites_to|given_retweets_to}.json
- %dt ユーザー情報。include_user_stats は標準で有効になります。
+ %dt ユーザー情報
%dd /users/info.json
%h3 パラメータ
%dl
@@ -24,23 +24,18 @@
%dt screen_name_b or user_id_b
%dd
%p Twitter アカウントのもの
- %p 有無で結果が変わります
- %p favorited_by などのみ。なんとなくわかるとおもう
- %dt include_user
- %dd
- %p true or false
- %p default: false
- %p 共通。ふぁぼ/RTしたユーザー情報を含めるか。重め
- %dt include_user_stats
- %dd
- %p true or false
- %p default: false
- %p 共通。ふぁぼ/RTしたユーザーのふぁぼられなどの情報を含めるか。すごく重いです
+ %p 有無で結果が変わる
+ %p 他ユーザーが関係してくるもののみ。「favorited_by の場合は screen_name_b にふぁぼられた screen_name のツイート」
%dt count
%dd
%p 1-100
%p default: 10
%p リストのみ。件数
+ %dt max_id
+ %dd
+ %p 数値
+ %p default: -1
+ %p Twitter API のものと同じ挙動
%dt page
%dd
%p 1-
diff --git a/app/views/shared/_sidebar_users.html.haml b/app/views/shared/_sidebar_users.html.haml
index 05e2377..c5475ce 100644
--- a/app/views/shared/_sidebar_users.html.haml
+++ b/app/views/shared/_sidebar_users.html.haml
@@ -34,7 +34,7 @@
%li
= link_to "favorited by", :controller => "users", :action => "favorited_by", :screen_name => @user.screen_name
%li
- = link_to "retweted by", :controller => "users", :action => "retweeted_by", :screen_name => @user.screen_name
+ = link_to "retweeted by", :controller => "users", :action => "retweeted_by", :screen_name => @user.screen_name
%li
= link_to "given favorites", :controller => "users", :action => "given_favorites_to", :screen_name => @user.screen_name
%li
diff --git a/client/worker.rb b/client/worker.rb
index d5b03ec..8edad41 100644
--- a/client/worker.rb
+++ b/client/worker.rb
@@ -189,8 +189,7 @@ class Worker
elsif hash[:user]
# tweet
if hash[:retweeted_status]
- if hash[:retweeted_status][:user][:id] == user_id ||
- hash[:user][:id] == user_id
+ if hash[:retweeted_status][:user][:id] == user_id || hash[:user][:id] == user_id
send_retweet.call(hash)
end
elsif hash[:user][:id] == user_id
diff --git a/config/unicorn.rb b/config/unicorn.rb
index 23c4869..370d9d2 100644
--- a/config/unicorn.rb
+++ b/config/unicorn.rb
@@ -15,7 +15,7 @@ before_fork do |server, worker|
ActiveRecord::Base.connection.disconnect!
end
- old_pid = "#{server.config[:pid]}.old"
+ old_pid = "#{server.config[:pid]}.oldbin"
unless old_pid == server.pid
begin
Process.kill :QUIT, File.read(old_pid).to_i
diff --git a/db/migrate/20130413042256_my_sql_change_charset.rb b/db/migrate/20130413042256_my_sql_change_charset.rb
new file mode 100644
index 0000000..bb0ad57
--- /dev/null
+++ b/db/migrate/20130413042256_my_sql_change_charset.rb
@@ -0,0 +1,21 @@
+class MySqlChangeCharset < ActiveRecord::Migration
+ def change
+ if /^mysql2?$/i =~ ActiveRecord::Base.connection.adapter_name
+ charset = "utf8mb4"
+ collation = "utf8mb4_general_ci"
+
+ # database
+ execute "ALTER DATABASE #{connection.current_database} DEFAULT CHARACTER SET #{charset} COLLATE #{collation}"
+
+ # schema_migrations
+ execute "ALTER TABLE schema_migrations CHANGE version version VARCHAR(191) CHARACTER SET #{charset} COLLATE #{collation}"
+
+ # table
+ connection.tables.each do |table|
+ execute "ALTER TABLE #{table} CONVERT TO CHARACTER SET #{charset} COLLATE #{collation}"
+ end
+ else
+ raise ActiveRecord::IrreversibleMigration.new("Migration error: Unsupported database for migration to utf8mb4 support.")
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 817847c..1e35c00 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20130403160821) do
+ActiveRecord::Schema.define(version: 20130413042256) do
create_table "accounts", force: true do |t|
t.integer "user_id", limit: 8, null: false
@@ -62,12 +62,12 @@ ActiveRecord::Schema.define(version: 20130403160821) do
add_index "stolen_tweets", ["tweet_id"], name: "index_stolen_tweets_on_tweet_id", unique: true
create_table "tweets", force: true do |t|
- t.text "text", null: false
- t.text "source"
- t.integer "user_id", limit: 8, null: false
+ t.text "text", limit: 16777215, null: false
+ t.text "source", limit: 16777215
+ t.integer "user_id", limit: 8, null: false
t.datetime "tweeted_at"
- t.integer "favorites_count", default: 0
- t.integer "retweets_count", default: 0
+ t.integer "favorites_count", default: 0
+ t.integer "retweets_count", default: 0
end
add_index "tweets", ["user_id"], name: "index_tweets_on_user_id"
@@ -75,12 +75,12 @@ ActiveRecord::Schema.define(version: 20130403160821) do
create_table "users", force: true do |t|
t.string "screen_name"
t.string "name"
- t.text "profile_image_url"
+ t.text "profile_image_url", limit: 16777215
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "protected"
end
- add_index "users", ["screen_name"], name: "index_users_on_screen_name"
+ add_index "users", ["screen_name"], name: "index_users_on_screen_name", length: {"screen_name"=>191}
end
diff --git a/spec/models/tweet_spec.rb b/spec/models/tweet_spec.rb
index 26045aa..78bf391 100644
--- a/spec/models/tweet_spec.rb
+++ b/spec/models/tweet_spec.rb
@@ -62,7 +62,7 @@ describe Tweet do
end
it "反応数順" do
- tweets = Tweet.order_by_reactions.limit(2)
+ tweets = Tweet.order_by_reactions
tweets.first.retweets.count.should be >= tweets.last.retweets.count
end