From f7d6c62ce0a02542f3ea2953ecb96a2900638934 Mon Sep 17 00:00:00 2001 From: stuppie Date: Mon, 5 Oct 2026 13:00:52 -0600 Subject: dont build balances for products with 0 txs --- generalresearch/models/thl/product.py | 16 +++++++++++++--- pyproject.toml | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/generalresearch/models/thl/product.py b/generalresearch/models/thl/product.py index 16288f6..2f95f0f 100644 --- a/generalresearch/models/thl/product.py +++ b/generalresearch/models/thl/product.py @@ -85,9 +85,7 @@ if TYPE_CHECKING: PRODUCT_BALANCES_METRICS_CACHE_KEY = "metrics:product_balances" -PRODUCT_USER_WALLET_BALANCES_METRICS_CACHE_KEY = ( - "metrics:product_user_wallet_balances" -) +PRODUCT_USER_WALLET_BALANCES_METRICS_CACHE_KEY = "metrics:product_user_wallet_balances" # fmt: off @@ -1165,6 +1163,7 @@ class Product(BaseModel, validate_assignment=True): "If the df is empty, we can also assume that there should be no " "transactions in the ledger." ) + return df = df.set_index("time_idx") @@ -1215,6 +1214,11 @@ class Product(BaseModel, validate_assignment=True): filters=filters, ) df = client.compute(collections=ddf, sync=True) + if df.empty: + LOG.warning( + f"Product({self.uuid=}).prebuild_private_balance empty dataframe" + ) + return s = df.set_index("time_idx").sum() @@ -1267,6 +1271,12 @@ class Product(BaseModel, validate_assignment=True): force_rr_latest=False, ) user_wallet_df = client.compute(ddf, sync=True) + if user_wallet_df.empty: + LOG.warning( + f"Product({self.uuid=}).prebuild_user_wallet_balances empty dataframe" + ) + return + result = ProductUserWalletBalances.from_pop_ledger( input_data=user_wallet_df, product_id=self.uuid, diff --git a/pyproject.toml b/pyproject.toml index e1d8824..53e4201 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "generalresearch" -version = "3.6.8" +version = "3.6.9" description = "Python Utilities for General Research" readme = "README.md" requires-python = ">=3.14" -- cgit v1.2.3