fix for vrfs-1476 - scoring should store the detail data

This commit is contained in:
Scott Comer 2014-05-21 21:30:43 -05:00
parent 4a76e0c983
commit 09231c5fe6
5 changed files with 15 additions and 5 deletions

View File

@ -156,3 +156,4 @@ scheduled_sessions.sql
add_last_jam_user_fields.sql add_last_jam_user_fields.sql
remove_lat_lng_user_fields.sql remove_lat_lng_user_fields.sql
update_get_work_for_larger_radius.sql update_get_work_for_larger_radius.sql
remember_extra_scoring_data.sql

View File

@ -0,0 +1,3 @@
-- add column to hold the raw scoring data that the client posted.
alter table scores add column scoring_data varchar(4000);

View File

@ -5,15 +5,15 @@ module JamRuby
self.table_name = 'scores' self.table_name = 'scores'
attr_accessible :alocidispid, :anodeid, :aaddr, :blocidispid, :bnodeid, :baddr, :score, :score_dt, :scorer attr_accessible :alocidispid, :anodeid, :aaddr, :blocidispid, :bnodeid, :baddr, :score, :score_dt, :scorer, :scoring_data
default_scope order('score_dt desc') default_scope order('score_dt desc')
def self.createx(alocidispid, anodeid, aaddr, blocidispid, bnodeid, baddr, score, score_dt=nil) def self.createx(alocidispid, anodeid, aaddr, blocidispid, bnodeid, baddr, score, score_dt=nil, score_data=nil)
score_dt = Time.new.utc if score_dt.nil? score_dt = Time.new.utc if score_dt.nil?
score = score.ceil score = score.ceil
raise "score must be positive" if score <= 0 raise "score must be positive" if score <= 0
Score.create(alocidispid: alocidispid, anodeid: anodeid, aaddr: aaddr, blocidispid: blocidispid, bnodeid: bnodeid, baddr: baddr, score: score, scorer: 0, score_dt: score_dt) Score.create(alocidispid: alocidispid, anodeid: anodeid, aaddr: aaddr, blocidispid: blocidispid, bnodeid: bnodeid, baddr: baddr, score: score, scorer: 0, score_dt: score_dt, scoring_data: score_data)
Score.create(alocidispid: blocidispid, anodeid: bnodeid, aaddr: baddr, blocidispid: alocidispid, bnodeid: anodeid, baddr: aaddr, score: score, scorer: 1, score_dt: score_dt) if alocidispid != blocidispid Score.create(alocidispid: blocidispid, anodeid: bnodeid, aaddr: baddr, blocidispid: alocidispid, bnodeid: anodeid, baddr: aaddr, score: score, scorer: 1, score_dt: score_dt) if alocidispid != blocidispid
end end

View File

@ -4,7 +4,7 @@ describe Score do
before do before do
Score.delete_all Score.delete_all
Score.createx(1234, 'anodeid', 0x01020304, 2345, 'bnodeid', 0x02030405, 20, nil) Score.createx(1234, 'anodeid', 0x01020304, 2345, 'bnodeid', 0x02030405, 20, nil, 'foo')
Score.createx(1234, 'anodeid', 0x01020304, 3456, 'cnodeid', 0x03040506, 30, nil) Score.createx(1234, 'anodeid', 0x01020304, 3456, 'cnodeid', 0x03040506, 30, nil)
Score.createx(1234, 'anodeid', 0x01020304, 3456, 'cnodeid', 0x03040506, 40, Time.new.utc-3600) Score.createx(1234, 'anodeid', 0x01020304, 3456, 'cnodeid', 0x03040506, 40, Time.new.utc-3600)
end end
@ -25,6 +25,7 @@ describe Score do
s.score.should == 20 s.score.should == 20
s.scorer.should == 0 s.scorer.should == 0
s.score_dt.should_not be_nil s.score_dt.should_not be_nil
s.scoring_data.should eq('foo')
end end
it 'b to a' do it 'b to a' do
@ -39,6 +40,7 @@ describe Score do
s.score.should == 20 s.score.should == 20
s.scorer.should == 1 s.scorer.should == 1
s.score_dt.should_not be_nil s.score_dt.should_not be_nil
s.scoring_data.should be_nil
end end
it 'a to c' do it 'a to c' do
@ -53,6 +55,7 @@ describe Score do
s.score.should == 30 s.score.should == 30
s.scorer.should == 0 s.scorer.should == 0
s.score_dt.should_not be_nil s.score_dt.should_not be_nil
s.scoring_data.should be_nil
end end
it 'c to a' do it 'c to a' do
@ -67,6 +70,7 @@ describe Score do
s.score.should == 30 s.score.should == 30
s.scorer.should == 1 s.scorer.should == 1
s.score_dt.should_not be_nil s.score_dt.should_not be_nil
s.scoring_data.should be_nil
end end
it 'delete a to c' do it 'delete a to c' do

View File

@ -35,11 +35,13 @@ class ApiScoringController < ApiController
def record # aclientid, aAddr, bclientid, bAddr, score returns nothing def record # aclientid, aAddr, bclientid, bAddr, score returns nothing
#puts "================= record #{params.inspect}" #puts "================= record #{params.inspect}"
aclientid = params[:aclientid] aclientid = params[:aclientid]
aip_address = params[:aAddr] aip_address = params[:aAddr]
bclientid = params[:bclientid] bclientid = params[:bclientid]
bip_address = params[:bAddr] bip_address = params[:bAddr]
score = params[:score] score = params[:score]
score_data = params.to_s
if aclientid.nil? then render :json => {message: 'aclientid not specified'}, :status => 400; return end if aclientid.nil? then render :json => {message: 'aclientid not specified'}, :status => 400; return end
if aip_address.nil? then render :json => {message: 'aAddr not specified'}, :status => 400; return end if aip_address.nil? then render :json => {message: 'aAddr not specified'}, :status => 400; return end
@ -80,7 +82,7 @@ class ApiScoringController < ApiController
if bisp.nil? or bloc.nil? then render :json => {message: 'b\'s location or isp not found'}, :status => 404; return end if bisp.nil? or bloc.nil? then render :json => {message: 'b\'s location or isp not found'}, :status => 404; return end
blocidispid = bloc.locid*1000000+bisp.coid blocidispid = bloc.locid*1000000+bisp.coid
JamRuby::Score.createx(alocidispid, aclientid, aAddr, blocidispid, bclientid, bAddr, score.ceil, nil) JamRuby::Score.createx(alocidispid, aclientid, aAddr, blocidispid, bclientid, bAddr, score.ceil, nil, score_data)
render :json => {}, :status => 200 render :json => {}, :status => 200
end end