Skip to content
Snippets Groups Projects
Commit 9f6e71a4 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch 'bw_issue_134' into 'develop'

issue 134

See merge request !476

(cherry picked from commit 31529ec2)

9be3af99 Issue #135
parent 02b28201
No related branches found
No related tags found
2 merge requests!519Merge branch 'bw_issue_134' into 'develop',!478Changes done in the MR 476 cherry-picked into master.
...@@ -110,6 +110,27 @@ $BODY$ ...@@ -110,6 +110,27 @@ $BODY$
DROP FUNCTION IF EXISTS calculate_account_reputations_for_block; DROP FUNCTION IF EXISTS calculate_account_reputations_for_block;
DROP TABLE IF EXISTS __new_reputation_data;
CREATE UNLOGGED TABLE IF NOT EXISTS __new_reputation_data
(
id integer,
author_id integer,
voter_id integer,
rshares bigint,
prev_rshares bigint
);
DROP TABLE IF EXISTS __tmp_accounts;
CREATE UNLOGGED TABLE IF NOT EXISTS __tmp_accounts
(
id integer,
reputation bigint,
is_implicit boolean,
changed boolean
);
CREATE OR REPLACE FUNCTION calculate_account_reputations_for_block(_block_num INT, _tracked_account VARCHAR DEFAULT NULL::VARCHAR) CREATE OR REPLACE FUNCTION calculate_account_reputations_for_block(_block_num INT, _tracked_account VARCHAR DEFAULT NULL::VARCHAR)
RETURNS SETOF accountreputation RETURNS SETOF accountreputation
LANGUAGE 'plpgsql' LANGUAGE 'plpgsql'
...@@ -130,16 +151,9 @@ DECLARE ...@@ -130,16 +151,9 @@ DECLARE
__traced_author int; __traced_author int;
__account_name varchar; __account_name varchar;
BEGIN BEGIN
CREATE UNLOGGED TABLE IF NOT EXISTS __new_reputation_data
( DELETE FROM __new_reputation_data;
id integer,
author_id integer,
voter_id integer,
rshares bigint,
prev_rshares bigint
);
TRUNCATE TABLE __new_reputation_data;
INSERT INTO __new_reputation_data INSERT INTO __new_reputation_data
SELECT rd.id, rd.author_id, rd.voter_id, rd.rshares, SELECT rd.id, rd.author_id, rd.voter_id, rd.rshares,
COALESCE((SELECT prd.rshares COALESCE((SELECT prd.rshares
...@@ -152,15 +166,9 @@ BEGIN ...@@ -152,15 +166,9 @@ BEGIN
ORDER BY rd.id ORDER BY rd.id
; ;
CREATE UNLOGGED TABLE IF NOT EXISTS __tmp_accounts
(
id integer,
reputation bigint,
is_implicit boolean,
changed boolean
);
TRUNCATE TABLE __tmp_accounts; DELETE FROM __tmp_accounts;
INSERT INTO __tmp_accounts INSERT INTO __tmp_accounts
SELECT ha.id, ha.reputation, ha.is_implicit, false AS changed SELECT ha.id, ha.reputation, ha.is_implicit, false AS changed
FROM __new_reputation_data rd FROM __new_reputation_data rd
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment