From 45fbc968fc90ac1661baa2121036fd471a63aa0c Mon Sep 17 00:00:00 2001
From: Michal Zander <mzander@syncad.com>
Date: Thu, 27 Feb 2025 12:19:05 +0000
Subject: [PATCH] Remove block parameter from aggregated history

---
 backend/aggregated_history.sql                | 21 +++++++------------
 .../get_history_aggregation.sql               |  3 +--
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/backend/aggregated_history.sql b/backend/aggregated_history.sql
index 19d3040..b1cbffb 100644
--- a/backend/aggregated_history.sql
+++ b/backend/aggregated_history.sql
@@ -3,8 +3,7 @@ SET ROLE btracker_owner;
 DROP TYPE IF EXISTS balance_history_aggregation CASCADE;
 CREATE TYPE balance_history_aggregation AS (
     date TIMESTAMP,
-    balance BIGINT,
-    block INT
+    balance BIGINT
 );
 
 CREATE OR REPLACE VIEW balance_history_by_year AS
@@ -63,8 +62,7 @@ BEGIN
     RETURN QUERY (
       SELECT 
         fb.date,
-        fb.balance,
-        fb.block
+        fb.balance
       FROM get_balance_history_by_day(
         _account_id,
         _coin_type,
@@ -77,8 +75,7 @@ BEGIN
     RETURN QUERY (
       SELECT 
         fb.date,
-        fb.balance,
-        fb.block
+        fb.balance
       FROM get_balance_history_by_month(
         _account_id,
         _coin_type,
@@ -91,8 +88,7 @@ BEGIN
     RETURN QUERY (
       SELECT 
         fb.date,
-        fb.balance,
-        fb.block
+        fb.balance
       FROM get_balance_history_by_year(
         _account_id,
         _coin_type,
@@ -182,8 +178,7 @@ RETURN QUERY (
   )
   SELECT 
     LEAST(fb.date + INTERVAL '1 day' - INTERVAL '1 second', CURRENT_TIMESTAMP)::TIMESTAMP AS adjusted_date,
-    fb.balance,
-    fb.source_op_block
+    fb.balance
   FROM filled_balances fb
   ORDER BY
     (CASE WHEN _direction = 'desc' THEN fb.date ELSE NULL END) DESC,
@@ -266,8 +261,7 @@ RETURN QUERY (
   )
   SELECT 
     LEAST(fb.date + INTERVAL '1 month' - INTERVAL '1 second', CURRENT_TIMESTAMP)::TIMESTAMP AS adjusted_date,
-    fb.balance,
-    fb.source_op_block
+    fb.balance
   FROM filled_balances fb
   ORDER BY
     (CASE WHEN _direction = 'desc' THEN fb.date ELSE NULL END) DESC,
@@ -350,8 +344,7 @@ RETURN QUERY (
   )
   SELECT 
     LEAST(fb.date + INTERVAL '1 year' - INTERVAL '1 second', CURRENT_TIMESTAMP)::TIMESTAMP AS adjusted_date,
-    fb.balance,
-    fb.source_op_block
+    fb.balance
   FROM filled_balances fb
   ORDER BY
     (CASE WHEN _direction = 'desc' THEN fb.date ELSE NULL END) DESC,
diff --git a/endpoints/account-balances/get_history_aggregation.sql b/endpoints/account-balances/get_history_aggregation.sql
index ac9cfeb..c2331ed 100644
--- a/endpoints/account-balances/get_history_aggregation.sql
+++ b/endpoints/account-balances/get_history_aggregation.sql
@@ -146,8 +146,7 @@ BEGIN
     SELECT to_json(array_agg(row)) FROM (
       SELECT 
         fb.date,
-        fb.balance::TEXT,
-        fb.block
+        fb.balance::TEXT
       FROM get_balance_history_aggregation(
         _account_id,
         _coin_type,
-- 
GitLab