From af8ec930883dc746e8b41b37bc5041d564315764 Mon Sep 17 00:00:00 2001
From: ABW <andrzejl@syncad.com>
Date: Thu, 6 Aug 2020 00:03:32 +0200
Subject: [PATCH] [ABW]: [Fix] wrong field used in condition

---
 hive/indexer/votes.py | 5 +++--
 tests/tests_api       | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/hive/indexer/votes.py b/hive/indexer/votes.py
index 85492eb2a..312b0820c 100644
--- a/hive/indexer/votes.py
+++ b/hive/indexer/votes.py
@@ -106,11 +106,12 @@ class Votes:
                 ON CONFLICT ON CONSTRAINT hive_votes_ux1 DO
                 UPDATE
                   SET
-                    weight = (CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.id) WHEN true THEN hive_votes.weight ELSE EXCLUDED.weight END),
-                    rshares = (CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.id) WHEN true THEN hive_votes.rshares ELSE EXCLUDED.rshares END),
+                    weight = (CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.post_id) WHEN true THEN hive_votes.weight ELSE EXCLUDED.weight END),
+                    rshares = (CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.post_id) WHEN true THEN hive_votes.rshares ELSE EXCLUDED.rshares END),
                     vote_percent = EXCLUDED.vote_percent,
                     last_update = EXCLUDED.last_update,
                     num_changes = hive_votes.num_changes + 1
+                  WHERE hive_votes.voter_id = EXCLUDED.voter_id and hive_votes.author_id = EXCLUDED.author_id and hive_votes.permlink_id = EXCLUDED.permlink_id;
                 """
 
             values = []
diff --git a/tests/tests_api b/tests/tests_api
index 779f69cf2..619f51ed6 160000
--- a/tests/tests_api
+++ b/tests/tests_api
@@ -1 +1 @@
-Subproject commit 779f69cf2171b2dd6259cb6fc300cd3bea737edc
+Subproject commit 619f51ed6c85a016621b12fa1264c12c7d3d3156
-- 
GitLab