diff --git a/db/manifest b/db/manifest index e333987b2..9e2240259 100755 --- a/db/manifest +++ b/db/manifest @@ -148,4 +148,5 @@ affiliate_partners.sql chat_messages.sql diagnostics.sql user_mods.sql -connection_stale_expire.sql \ No newline at end of file +connection_stale_expire.sql +fix_connection_fields.sql diff --git a/db/up/fix_connection_fields.sql b/db/up/fix_connection_fields.sql new file mode 100644 index 000000000..183b1ee26 --- /dev/null +++ b/db/up/fix_connection_fields.sql @@ -0,0 +1,8 @@ +ALTER TABLE connections ALTER COLUMN user_id SET NOT NULL; +ALTER TABLE connections ALTER COLUMN ip_address SET NOT NULL; + +ALTER TABLE connections DROP COLUMN latitude; +ALTER TABLE connections DROP COLUMN longitude; +ALTER TABLE connections DROP COLUMN countrycode; +ALTER TABLE connections DROP COLUMN region; +ALTER TABLE connections DROP COLUMN city; diff --git a/ruby/lib/jam_ruby/connection_manager.rb b/ruby/lib/jam_ruby/connection_manager.rb index 02a0f6891..59e7b8735 100644 --- a/ruby/lib/jam_ruby/connection_manager.rb +++ b/ruby/lib/jam_ruby/connection_manager.rb @@ -75,28 +75,13 @@ module JamRuby if location.nil? # todo what's a better default location? locidispid = 0 - latitude = 0.0 - longitude = 0.0 - countrycode = 'US' - region = 'TX' - city = 'Austin' else locidispid = locid*1000000+ispid - latitude = location.latitude - longitude = location.longitude - countrycode = location.countrycode - region = location.region - city = location.city end conn.ip_address = ip_address conn.addr = addr conn.locidispid = locidispid - conn.latitude = latitude - conn.longitude = longitude - conn.countrycode = countrycode - conn.region = region - conn.city = city conn.save!(validate: false) end @@ -230,24 +215,14 @@ SQL if location.nil? # todo what's a better default location? locidispid = 0 - latitude = 0.0 - longitude = 0.0 - countrycode = 'US' - region = 'TX' - city = 'Austin' else locidispid = locid*1000000+ispid - latitude = location.latitude - longitude = location.longitude - countrycode = location.countrycode - region = location.region - city = location.city end lock_connections(conn) - conn.exec("INSERT INTO connections (user_id, client_id, ip_address, client_type, addr, locidispid, latitude, longitude, countrycode, region, city, aasm_state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)", - [user_id, client_id, ip_address, client_type, addr, locidispid, latitude, longitude, countrycode, region, city, Connection::CONNECT_STATE.to_s]).clear + conn.exec("INSERT INTO connections (user_id, client_id, ip_address, client_type, addr, locidispid, aasm_state) VALUES ($1, $2, $3, $4, $5, $6, $7)", + [user_id, client_id, ip_address, client_type, addr, locidispid, Connection::CONNECT_STATE.to_s]).clear # we just created a new connection-if this is the first time the user has shown up, we need to send out a message to his friends conn.exec("SELECT count(user_id) FROM connections WHERE user_id = $1", [user_id]) do |result| diff --git a/ruby/spec/factories.rb b/ruby/spec/factories.rb index 2b5b85d88..30355116d 100644 --- a/ruby/spec/factories.rb +++ b/ruby/spec/factories.rb @@ -91,11 +91,6 @@ FactoryGirl.define do as_musician true addr 0 locidispid 0 - latitude 0.0 - longitude 0.0 - countrycode 'US' - region 'TX' - city 'Austin' client_type 'client' end diff --git a/ruby/spec/jam_ruby/connection_manager_spec.rb b/ruby/spec/jam_ruby/connection_manager_spec.rb index c1e52c44d..25c659529 100644 --- a/ruby/spec/jam_ruby/connection_manager_spec.rb +++ b/ruby/spec/jam_ruby/connection_manager_spec.rb @@ -78,11 +78,6 @@ describe ConnectionManager do cc.ip_address.should eql("1.1.1.1") cc.addr.should == 0x01010101 cc.locidispid.should == 17192000002 - cc.latitude.should == 30.2076 - cc.longitude.should == -97.8587 - cc.city.should eql('Austin') - cc.region.should eql('TX') - cc.countrycode.should eql('US') count = @connman.delete_connection(client_id) count.should == 0 @@ -113,11 +108,6 @@ describe ConnectionManager do cc.ip_address.should eql("1.1.1.1") cc.addr.should == 0x01010101 cc.locidispid.should == 17192000002 - cc.latitude.should == 30.2076 - cc.longitude.should == -97.8587 - cc.city.should eql('Austin') - cc.region.should eql('TX') - cc.countrycode.should eql('US') @connman.reconnect(cc, nil, "33.1.2.3") @@ -126,11 +116,6 @@ describe ConnectionManager do cc.ip_address.should eql("33.1.2.3") cc.addr.should == 0x21010203 cc.locidispid.should == 30350000003 - cc.latitude.should == 29.7633 - cc.longitude.should == -95.3633 - cc.city.should eql('Houston') - cc.region.should eql('TX') - cc.countrycode.should eql('US') count = @connman.delete_connection(client_id) count.should == 0 diff --git a/ruby/spec/jam_ruby/models/track_spec.rb b/ruby/spec/jam_ruby/models/track_spec.rb index be63c781b..8f59526d9 100644 --- a/ruby/spec/jam_ruby/models/track_spec.rb +++ b/ruby/spec/jam_ruby/models/track_spec.rb @@ -4,7 +4,7 @@ describe Track do let (:user) {FactoryGirl.create(:user) } let (:music_session) { FactoryGirl.create(:music_session, :creator => user)} - let (:connection) { FactoryGirl.create(:connection, :music_session => music_session) } + let (:connection) { FactoryGirl.create(:connection, :user => user, :music_session => music_session) } let (:track) { FactoryGirl.create(:track, :connection => connection)} let (:track2) { FactoryGirl.create(:track, :connection => connection)} let (:msuh) {FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => user, :client_id => connection.client_id) } diff --git a/web/spec/factories.rb b/web/spec/factories.rb index e600b24b9..f363066b5 100644 --- a/web/spec/factories.rb +++ b/web/spec/factories.rb @@ -89,11 +89,6 @@ FactoryGirl.define do as_musician true addr 0 locidispid 0 - latitude 0.0 - longitude 0.0 - countrycode 'US' - region 'TX' - city 'Austin' client_type 'client' end diff --git a/websocket-gateway/spec/factories.rb b/websocket-gateway/spec/factories.rb index 9e716f56a..ae4e6a90e 100644 --- a/websocket-gateway/spec/factories.rb +++ b/websocket-gateway/spec/factories.rb @@ -35,11 +35,6 @@ FactoryGirl.define do factory :connection, :class => JamRuby::Connection do addr 0 locidispid 0 - latitude 0.0 - longitude 0.0 - countrycode 'US' - region 'TX' - city 'Austin' ip_address '1.1.1.1' as_musician true client_type 'client'