Skip to content

Commit

Permalink
fix typo, change charset to utf8mb4(MySQL), fix importing
Browse files Browse the repository at this point in the history
  • Loading branch information
re4k committed Apr 13, 2013
1 parent 62cb571 commit 84e85f4
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 48 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
33 changes: 17 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -199,7 +200,7 @@ DEPENDENCIES
jquery-rails
kaminari
msgpack
mysql2
mysql2 (> 0.3.12b)
omniauth-twitter!
rails (= 4.0.0.beta1)
rails_config
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def page; get_int(params[:page], nil){|i| i > 0} end

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]
Expand Down
2 changes: 1 addition & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def import_favorites(id)
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
Expand Down
2 changes: 1 addition & 1 deletion app/models/favorite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.from_hash(hash)

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
Expand Down
21 changes: 8 additions & 13 deletions app/views/main/api.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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-
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_sidebar_users.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions client/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ def receive_account(msg)
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
Expand Down
2 changes: 1 addition & 1 deletion config/unicorn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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
Expand Down
21 changes: 21 additions & 0 deletions db/migrate/20130413042256_my_sql_change_charset.rb
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -62,25 +62,25 @@
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"

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
2 changes: 1 addition & 1 deletion spec/models/tweet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
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

Expand Down

0 comments on commit 84e85f4

Please sign in to comment.