diff --git a/squeaknode/db/squeak_db.py b/squeaknode/db/squeak_db.py index f6f03b94..3a39d6bf 100644 --- a/squeaknode/db/squeak_db.py +++ b/squeaknode/db/squeak_db.py @@ -665,25 +665,25 @@ class SqueakDb: num_squeaks = row["num_squeaks"] return num_squeaks - def number_of_squeaks_with_address_with_block( - self, - address: str, - block_height: int, - ) -> int: - """ Get number of squeaks with address with block height. """ - s = ( - select([ - func.count().label("num_squeaks"), - ]) - .select_from(self.squeaks) - .where(self.squeaks.c.author_address == address) - .where(self.squeaks.c.n_block_height == block_height) - ) - with self.get_connection() as connection: - result = connection.execute(s) - row = result.fetchone() - num_squeaks = row["num_squeaks"] - return num_squeaks + # def number_of_squeaks_with_address_with_block( + # self, + # address: str, + # block_height: int, + # ) -> int: + # """ Get number of squeaks with address with block height. """ + # s = ( + # select([ + # func.count().label("num_squeaks"), + # ]) + # .select_from(self.squeaks) + # .where(self.squeaks.c.author_address == address) + # .where(self.squeaks.c.n_block_height == block_height) + # ) + # with self.get_connection() as connection: + # result = connection.execute(s) + # row = result.fetchone() + # num_squeaks = row["num_squeaks"] + # return num_squeaks def number_of_squeaks_with_address_in_block_range( self, diff --git a/tests/db/test_squeak_db.py b/tests/db/test_squeak_db.py index 53e09167..cc120ae7 100644 --- a/tests/db/test_squeak_db.py +++ b/tests/db/test_squeak_db.py @@ -639,3 +639,19 @@ def test_get_number_of_squeaks( num_squeaks = squeak_db.get_number_of_squeaks() assert num_squeaks == len(inserted_squeak_hashes) + + +def test_number_of_squeaks_with_address_in_block_range( + squeak_db, + address_str, + inserted_squeak_hashes, +): + min_block = 43 + max_block = 91 + num_squeaks = squeak_db.number_of_squeaks_with_address_in_block_range( + address=address_str, + min_block=min_block, + max_block=max_block, + ) + + assert num_squeaks == max_block - min_block + 1