import json

from aiohttp import web

from snek.system.view import BaseView


class StatsView(BaseView):

    async def get(self):
        data = await self.app.cache.get_stats()
        data = json.dumps({"total": len(data), "stats": data}, default=str, indent=1)
        return web.Response(text=data, content_type="application/json")
