Permalink
Browse files

Revert db method

  • Loading branch information...
mirakui committed Oct 22, 2017
1 parent 6dcb723 commit 9dcfd8ae9a2c1b0059a4668288382920b3a291d6
Showing with 19 additions and 7 deletions.
  1. +19 −7 isubata/webapp/ruby/app.rb
View
@@ -405,20 +405,32 @@ def redis
Thread.current[:isubata_redis] ||= Redis.new(url: ENV.fetch('ISUBATA_REDIS_URL', 'redis://localhost:6379/0'))
end
# def db
# return Thread.current[:isubata_db] if Thread.current[:isubata_db]
# client = Mysql2::Client.new(
# host: ENV.fetch('ISUBATA_DB_HOST') { 'localhost' },
# port: ENV.fetch('ISUBATA_DB_PORT') { '3306' },
# username: ENV.fetch('ISUBATA_DB_USER') { 'root' },
# password: ENV.fetch('ISUBATA_DB_PASSWORD') { '' },
# database: 'isubata',
# encoding: 'utf8mb4'
# )
# client.extend(MysqlMonkeyPatch) unless ENV['ISUCON7_DISABLE_LOGS'] == '1'
# client.query('SET SESSION sql_mode=\'TRADITIONAL,NO_AUTO_VALUE_ON_ZERO,ONLY_FULL_GROUP_BY\'')
# Thread.current[:isubata_db] = client
# client
# end
def db
return Thread.current[:isubata_db] if Thread.current[:isubata_db]
client = Mysql2::Client.new(
Thread.current[:isubata_db] ||= Mysql2::Client.new(
host: ENV.fetch('ISUBATA_DB_HOST') { 'localhost' },
port: ENV.fetch('ISUBATA_DB_PORT') { '3306' },
username: ENV.fetch('ISUBATA_DB_USER') { 'root' },
password: ENV.fetch('ISUBATA_DB_PASSWORD') { '' },
database: 'isubata',
encoding: 'utf8mb4'
)
client.extend(MysqlMonkeyPatch) unless ENV['ISUCON7_DISABLE_LOGS'] == '1'
client.query('SET SESSION sql_mode=\'TRADITIONAL,NO_AUTO_VALUE_ON_ZERO,ONLY_FULL_GROUP_BY\'')
Thread.current[:isubata_db] = client
client
).tap do |mysql|
mysql.query('SET SESSION sql_mode=\'TRADITIONAL,NO_AUTO_VALUE_ON_ZERO,ONLY_FULL_GROUP_BY\'')
end
end
def db_get_user(user_id)

0 comments on commit 9dcfd8a

Please sign in to comment.