"""Bundled dashboard: memory snippet."""
import json


def register(ctx):
    from dashboard_bundled.feeds import feed_memory_note

    ctx.register_dashboard_tile(
        {
            "id": "memory",
            "title": "Memory",
            "path": "/tile",
            "refresh_seconds": 14400,
            "priority": 4,
        }
    )

    def route_handler(req):
        body = json.dumps(feed_memory_note(), ensure_ascii=False)
        return {
            "status": 200,
            "headers": {"Content-Type": "application/json; charset=utf-8"},
            "body": body,
        }

    ctx.register_route_handler(route_handler)
