VRFS-1430 merge conflict correction

This commit is contained in:
Jonathan Kolyer 2014-10-01 22:12:48 +00:00
commit 3080a92096
6 changed files with 35 additions and 15 deletions

View File

@ -214,4 +214,6 @@ fix_find_session_sorting_2216a.sql
fix_find_session_sorting_2216b.sql
fix_find_session_sorting_2216c.sql
entabulate_current_network_scores.sql
discard_scores_changed.sql
emails_from_update.sql

View File

@ -0,0 +1,14 @@
DROP FUNCTION IF EXISTS discard_scores();
CREATE FUNCTION discard_scores () RETURNS VOID AS $$
BEGIN
WITH scores_to_delete AS (
SELECT alocidispid, blocidispid, scorer, created_at FROM (SELECT *, row_number() OVER (PARTITION BY alocidispid, blocidispid, scorer ORDER BY scores.created_at DESC) AS rownum FROM scores) tmp WHERE rownum > 6
)
DELETE FROM scores USING scores_to_delete WHERE
scores.alocidispid = scores_to_delete.alocidispid AND
scores.blocidispid = scores_to_delete.blocidispid AND
scores.scorer = scores_to_delete.scorer AND
scores.created_at = scores_to_delete.created_at;
RETURN;
END;
$$ LANGUAGE plpgsql;

View File

@ -532,18 +532,19 @@ describe Score do
Score.createx(LOCA, NODEA, ADDRA, LOCB, NODEB, ADDRB, 20, nil)
Score.createx(LOCA, NODEA, ADDRA, LOCB, NODEB, ADDRB, 20, nil)
Score.createx(LOCA, NODEA, ADDRA, LOCB, NODEB, ADDRB, 20, nil)
Score.createx(LOCA, NODEA, ADDRA, LOCB, NODEB, ADDRB, 20, nil)
Score.count.should == 10
Score.count.should == 12
Score.connection.execute("SELECT discard_scores()").check
Score.count.should == 10
Score.count.should == 12
Score.createx(LOCA, NODEA, ADDRA, LOCB, NODEB, ADDRB, 26, nil)
Score.connection.execute("UPDATE scores set created_at = TIMESTAMP '#{2.days.ago}' WHERE score = 26").cmdtuples.should == 2
Score.connection.execute("SELECT discard_scores()").check
Score.count.should == 10
Score.connection.execute("SELECT * FROM scores WHERE score = 20").ntuples.should == 10
Score.connection.execute("SELECT * FROM scores WHERE scorer = 0").ntuples.should == 5
Score.connection.execute("SELECT * FROM scores WHERE scorer = 1").ntuples.should == 5
Score.count.should == 12
Score.connection.execute("SELECT * FROM scores WHERE score = 20").ntuples.should == 12
Score.connection.execute("SELECT * FROM scores WHERE scorer = 0").ntuples.should == 6
Score.connection.execute("SELECT * FROM scores WHERE scorer = 1").ntuples.should == 6
Score.createx(LOCB, NODEB, ADDRB, LOCA, NODEA, ADDRA, 22, nil)
@ -551,18 +552,19 @@ describe Score do
Score.createx(LOCB, NODEB, ADDRB, LOCA, NODEA, ADDRA, 22, nil)
Score.createx(LOCB, NODEB, ADDRB, LOCA, NODEA, ADDRA, 22, nil)
Score.createx(LOCB, NODEB, ADDRB, LOCA, NODEA, ADDRA, 22, nil)
Score.createx(LOCB, NODEB, ADDRB, LOCA, NODEA, ADDRA, 22, nil)
Score.count.should == 20
Score.count.should == 24
Score.connection.execute("SELECT discard_scores()").check
Score.count.should == 20
Score.count.should == 24
Score.createx(LOCB, NODEB, ADDRB, LOCA, NODEA, ADDRA, 36, nil)
Score.connection.execute("UPDATE scores set created_at = TIMESTAMP '#{2.days.ago}' WHERE score = 36").cmdtuples.should == 2
Score.connection.execute("SELECT discard_scores()").check
Score.count.should == 20
Score.connection.execute("SELECT * FROM scores WHERE score = 22").ntuples.should == 10
Score.connection.execute("SELECT * FROM scores WHERE score = 22 AND scorer = 0").ntuples.should == 5
Score.connection.execute("SELECT * FROM scores WHERE score = 22 AND scorer = 1").ntuples.should == 5
Score.count.should == 24
Score.connection.execute("SELECT * FROM scores WHERE score = 22").ntuples.should == 12
Score.connection.execute("SELECT * FROM scores WHERE score = 22 AND scorer = 0").ntuples.should == 6
Score.connection.execute("SELECT * FROM scores WHERE score = 22 AND scorer = 1").ntuples.should == 6
end
end

View File

@ -422,7 +422,6 @@
function deleteNotification(notificationId) {
console.trace();
var url = "/api/users/" + context.JK.currentUserId + "/notifications/" + notificationId;
$.ajax({
type: "DELETE",

View File

@ -11,7 +11,8 @@ class VanillaForumsController < ApplicationController
user = {name: '', photourl: ''}
if current_user
user = {email: current_user.email, name: current_user.username,
name = current_user.admin ? "#{current_user.name} #{Rails.application.config.vanilla_staff_postfix}" : current_user.name
user = {email: current_user.email, name: name,
photourl: current_user.profile_pic,
uniqueid: current_user.username}
end
@ -37,7 +38,8 @@ class VanillaForumsController < ApplicationController
user = {}
if current_user
user = {'email' => current_user.email, 'name' => current_user.name,
name = current_user.admin ? "#{current_user.name} #{Rails.application.config.vanilla_staff_postfix}" : current_user.name
user = {'email' => current_user.email, 'name' => name,
'photourl' => current_user.resolved_photo_url,
'uniqueid' => current_user.id}

View File

@ -230,6 +230,7 @@ if defined?(Bundler)
config.vanilla_secret = 'bibbitybobbityslipperyslopes'
config.vanilla_url = 'http://forums.jamkazam.com'
config.vanilla_login_url = 'http://forums.jamkazam.com/entry/jsconnect'
config.vanilla_staff_postfix = '(JamKazam Staff)'
# we have to do this for a while until all www.jamkazam.com cookies are gone,
# and only .jamkazam.com cookies are around.. 2016?