def METHOD_NAME(appid: str, background_tasks: BackgroundTasks):
    if app := db.get_json_key(f"apps:{appid}"):
        compat_app = {
            "flatpakAppId": appid,
            "name": app.get("name"),
            "summary": app.get("summary"),
            "description": app.get("description"),
            "downloadFlatpakRefUrl": f"https://dl.flathub.org/repo/appstream/{appid}.flatpakref",
            "projectLicense": app.get("project_license"),
            "iconDesktopUrl": app.get("icon"),
            "iconMobileUrl": app.get("icon"),
            "homepageUrl": app.get("urls", {}).get("homepage"),
            "helpUrl": app.get("urls", {}).get("help"),
            "translateUrl": app.get("urls", {}).get("translate"),
            "bugtrackerUrl": app.get("urls", {}).get("bugtracker"),
            "donationUrl": app.get("urls", {}).get("donation"),
            "developerName": app.get("developer_name"),
            "categories": [
                {"name": category} for category in app.get("categories", [])
            ],
            "currentReleaseDescription": None,
            "currentReleaseVersion": None,
            "currentReleaseDate": None,
            "inStoreSinceDate": None,
            "screenshots": None,
        }
        if releases := app.get("releases"):
            release = releases[0]
            compat_app["currentReleaseVersion"] = release.get("version")
            compat_app["currentReleaseDescription"] = release.get("description")
            if release_ts := release.get("timestamp"):
                release_ts = int(release_ts)
                compat_app["currentReleaseDate"] = datetime.utcfromtimestamp(
                    release_ts
                ).strftime("%Y-%m-%d")
        if created_at := db.redis_conn.get(f"created_at:{appid}"):
            compat_app["inStoreSinceDate"] = created_at
        else:
            background_tasks.add_task(get_repo_creation_date, appid)
        if screenshots := app.get("screenshots"):
            screenshots = list(filter(None, screenshots))
            compat_screenshots = []
            for screenshot in screenshots:
                screenshots_sizes = sorted(
                    screenshot["sizes"].keys(), key=lambda res: int(res.split("x")[0])
                )
                if screenshots_sizes:
                    full_size = screenshots_sizes[-1]
                    thumb_size = screenshots_sizes[0]
                filename = list(screenshot["sizes"].values())[0].split("/")[-1]
                compat_screenshots.append(
                    {
                        "imgDesktopUrl": f"https://dl.flathub.org/repo/screenshots/{appid}-stable/{full_size}/{filename}",
                        "imgMobileUrl": f"https://dl.flathub.org/repo/screenshots/{appid}-stable/{full_size}/{filename}",
                        "thumbUrl": f"https://dl.flathub.org/repo/screenshots/{appid}-stable/{thumb_size}/{filename}",
                    }
                )
            compat_app["screenshots"] = compat_screenshots
        return compat_app