fix for vrfs-1476 - scoring should store the detail data
This commit is contained in:
parent
4a76e0c983
commit
09231c5fe6
|
|
@ -156,3 +156,4 @@ scheduled_sessions.sql
|
|||
add_last_jam_user_fields.sql
|
||||
remove_lat_lng_user_fields.sql
|
||||
update_get_work_for_larger_radius.sql
|
||||
remember_extra_scoring_data.sql
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -5,15 +5,15 @@ module JamRuby
|
|||
|
||||
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')
|
||||
|
||||
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 = score.ceil
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ describe Score do
|
|||
|
||||
before do
|
||||
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, 40, Time.new.utc-3600)
|
||||
end
|
||||
|
|
@ -25,6 +25,7 @@ describe Score do
|
|||
s.score.should == 20
|
||||
s.scorer.should == 0
|
||||
s.score_dt.should_not be_nil
|
||||
s.scoring_data.should eq('foo')
|
||||
end
|
||||
|
||||
it 'b to a' do
|
||||
|
|
@ -39,6 +40,7 @@ describe Score do
|
|||
s.score.should == 20
|
||||
s.scorer.should == 1
|
||||
s.score_dt.should_not be_nil
|
||||
s.scoring_data.should be_nil
|
||||
end
|
||||
|
||||
it 'a to c' do
|
||||
|
|
@ -53,6 +55,7 @@ describe Score do
|
|||
s.score.should == 30
|
||||
s.scorer.should == 0
|
||||
s.score_dt.should_not be_nil
|
||||
s.scoring_data.should be_nil
|
||||
end
|
||||
|
||||
it 'c to a' do
|
||||
|
|
@ -67,6 +70,7 @@ describe Score do
|
|||
s.score.should == 30
|
||||
s.scorer.should == 1
|
||||
s.score_dt.should_not be_nil
|
||||
s.scoring_data.should be_nil
|
||||
end
|
||||
|
||||
it 'delete a to c' do
|
||||
|
|
|
|||
|
|
@ -35,11 +35,13 @@ class ApiScoringController < ApiController
|
|||
def record # aclientid, aAddr, bclientid, bAddr, score returns nothing
|
||||
|
||||
#puts "================= record #{params.inspect}"
|
||||
|
||||
aclientid = params[:aclientid]
|
||||
aip_address = params[:aAddr]
|
||||
bclientid = params[:bclientid]
|
||||
bip_address = params[:bAddr]
|
||||
score = params[:score]
|
||||
score_data = params.to_s
|
||||
|
||||
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
|
||||
|
|
@ -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
|
||||
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
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue