Skip to content
Snippets Groups Projects
Commit a327aa3d authored by Roman Shishkin's avatar Roman Shishkin
Browse files

Add new /api/bucket route with all buckets

parent 28dbf46e
Branches main
Tags 0001.0
No related merge requests found
Pipeline #8272 passed
......@@ -59,3 +59,4 @@ docs/_build/
target/
.idea/
.DS_Store
FROM python:3.11-slim
FROM python:3.12-slim
ENV TZ=Europe/Moscow
......
version: '3.7'
services:
app:
build:
......
aiochclient==2.2.0
aiohttp==3.8.3
aiohttp-jinja2==1.5
aiochclient==2.6.0
aiohttp==3.9.5
aiohttp-jinja2==1.6
aiohttp-swagger==1.0.16
aioredis==1.3.1
aioredis-cluster==2.3.1
aioredis-cluster==2.7.0
aiosignal==1.3.1
anyio==3.6.2
async-timeout==4.0.2
attrs==22.2.0
cenao==0.9.2
certifi==2022.12.7
charset-normalizer==2.1.1
ciso8601==2.3.0
frozenlist==1.3.3
anyio==4.3.0
async-timeout==4.0.3
attrs==23.2.0
cenao==0.12.0
certifi==2024.2.2
charset-normalizer==3.3.2
ciso8601==2.3.1
frozenlist==1.4.1
h11==0.14.0
hiredis==2.1.1
httpcore==0.16.3
httpx==0.23.3
idna==3.4
Jinja2==3.1.2
MarkupSafe==2.1.2
mashumaro==3.5
multidict==6.0.4
prometheus-client==0.14.1
PyYAML==6.0
rfc3986==1.5.0
sniffio==1.3.0
sqlparse==0.4.3
typing_extensions==4.4.0
ujson==5.7.0
uvloop==0.17.0
yarl==1.8.2
hiredis==2.3.2
httpcore==1.0.5
httpx==0.27.0
idna==3.7
Jinja2==3.1.4
MarkupSafe==2.1.5
mashumaro==3.13
multidict==6.0.5
prometheus-client==0.20.0
PyYAML==6.0.1
rfc3986==2.0.0
sniffio==1.3.1
sqlparse==0.5.0
typing_extensions==4.11.0
ujson==5.9.0
uvloop==0.19.0
yarl==1.9.4
......@@ -12,7 +12,8 @@ from s3_checker.views import (
ScannerIndexView,
ScannerScanMissingView,
ScannerScanZeroView,
ScannerBucketView,
ScannerBucketAPIView,
ScannerBucketByNameAPIView,
ScannerStatsView,
ScannerStatsRemoveView,
)
......@@ -24,7 +25,8 @@ class ScannerAppFeature(AppFeature):
ScannerIndexView,
ScannerScanMissingView,
ScannerScanZeroView,
ScannerBucketView,
ScannerBucketAPIView,
ScannerBucketByNameAPIView,
ScannerStatsView,
ScannerStatsRemoveView,
]
......
......@@ -98,8 +98,32 @@ class ScannerStatsRemoveView(View):
})
class ScannerBucketView(View):
ROUTE = "/bucket/{bucket}"
class ScannerBucketAPIView(View):
ROUTE = "/api/bucket"
async def get(self, *args, **kwargs):
redis: Redis = self.app.ft.redis.client
# _buckets = await redis.zrange(f"{self.app.NAME}:buckets", 0, -1, withscores=True, encoding="utf-8")
# buckets = {}
# for bucket in _buckets:
# buckets[bucket[0]] = {
# "size": bucket[1]
# }
buckets = defaultdict(dict)
sizes = await redis.zrange(f"{self.app.NAME}:buckets", 0, -1, withscores=True, encoding="utf-8")
for size_bucket, size_size in sizes:
buckets[size_bucket]["size"] = size_size
counts = await redis.zrange(f"{self.app.NAME}:buckets:count", 0, -1, withscores=True, encoding="utf-8")
for count_bucket, count_count in counts:
buckets[count_bucket]["count"] = count_count
return {"buckets": buckets}
class ScannerBucketByNameAPIView(View):
ROUTE = "/api/bucket/{bucket}"
async def get(self, *args, **kwargs):
redis: Redis = self.app.ft.redis.client
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment