From 7e70b719edea052bfe32b046e9c93d82442230e4 Mon Sep 17 00:00:00 2001
From: mtrela <mtrela@syncad.com>
Date: Tue, 4 Aug 2020 12:42:21 +0200
Subject: [PATCH] Small fixes

---
 hive/indexer/posts.py             |  2 +-
 hive/server/condenser_api/tags.py | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hive/indexer/posts.py b/hive/indexer/posts.py
index 5c858ef51..549492200 100644
--- a/hive/indexer/posts.py
+++ b/hive/indexer/posts.py
@@ -304,7 +304,7 @@ class Posts:
               author,
               permlink,
               "NULL" if ( total_payout_value is None ) else ( "'{}'".format( legacy_amount(total_payout_value) ) ),
-              "NULL" if ( curators_vesting_payout is None ) else ( "'{}'".format( legacy_amount(curators_vesting_payout) ) ), #curator_payout_value
+              "NULL" if ( curator_payout_value is None ) else ( "'{}'".format( legacy_amount(curator_payout_value) ) ),
               "NULL" if ( author_rewards is None ) else author_rewards,
               "NULL" if ( author_rewards_hive is None ) else author_rewards_hive,
               "NULL" if ( author_rewards_hbd is None ) else author_rewards_hbd,
diff --git a/hive/server/condenser_api/tags.py b/hive/server/condenser_api/tags.py
index 7c687cfdd..cdf541ec1 100644
--- a/hive/server/condenser_api/tags.py
+++ b/hive/server/condenser_api/tags.py
@@ -29,10 +29,10 @@ async def get_trending_tags(context, start_tag: str = '', limit: int = 250):
 
     if start_tag:
         seek = """
-          HAVING SUM(payout) <= (
-            SELECT SUM(payout)
+          HAVING SUM(payout + pending_payout) <= (
+            SELECT SUM(payout + pending_payout)
               FROM hive_posts
-             WHERE is_paidout = '0'
+             WHERE is_paidout = '0' and is_deleted = false
                AND category_id = (SELECT id FROM hive_category_data WHERE category = :start_tag))
         """
     else:
@@ -42,11 +42,11 @@ async def get_trending_tags(context, start_tag: str = '', limit: int = 250):
       SELECT (SELECT category FROM hive_category_data WHERE id = category_id) as category,
              COUNT(*) AS total_posts,
              SUM(CASE WHEN depth = 0 THEN 1 ELSE 0 END) AS top_posts,
-             SUM(payout) AS total_payouts
+             SUM(payout + pending_payout) AS total_payouts
         FROM hive_posts
-       WHERE is_paidout = '0'
+       WHERE is_paidout = '0' and is_deleted = false
     GROUP BY category %s
-    ORDER BY SUM(payout) DESC
+    ORDER BY SUM(payout + pending_payout) DESC
        LIMIT :limit
     """ % seek
 
-- 
GitLab