Skip to content

Commit

Permalink
More #notests
Browse files Browse the repository at this point in the history
  • Loading branch information
squeaky-pl committed Sep 3, 2024
1 parent d0ffed9 commit 977cc60
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions bin/block-stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,33 @@ def run(limit: int, after: str) -> None:
Block.size > 0,
Block.updated_at >= datetime.datetime.fromisoformat(after),
)
.order_by(Block.updated_at.desc())
.order_by(Block.updated_at)
)
.limit(limit)
.all()
)

total_objects = 0
total_size = 0
valid_blocks = {}
for block in blocks:
if block.data_sha256 in valid_blocks:
continue

data = blockstore.get_from_blockstore(block.data_sha256)
print(
block.id,
block.data_sha256,
block.filename or "no-filename",
block.size if data else None,
[(part.content_disposition, part.message_id) for part in block.parts],
)

if data:
total_objects += 1
total_size += block.size
valid_blocks[block.data_sha256] = len(data)

print(f"Total objects: {total_objects}, total size: {total_size}")
print(f"Total blocks: {len(blocks)}")
print(
f"Blocks with objects: {len(valid_blocks)}, size: {sum(valid_blocks.values())}"
)


if __name__ == "__main__":
Expand Down

0 comments on commit 977cc60

Please sign in to comment.