{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Fix Jobs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from api import BigApi\n",
    "BigApi.init(\".admin.env\")\n",
    "BigApi.adminLogin()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "jobId = \"\"\n",
    "r = BigApi.adminGetRaw(f\"/admin/fabricator/job/{jobId}/scan\")\n",
    "\n",
    "# stream the requests output to a file\n",
    "with open(\"./tmp_scan.zip\", \"wb\") as f:\n",
    "    r.raw.decode_content = True\n",
    "    f.write(r.content)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "binaryWaxIdList = [\n",
    "    [\"0101\", \"10111\", \"10011\", \"00100\"], # we know this one exists\n",
    "\n",
    "    [\"1110\", \"10010\", \"01111\", \"01111\"],\n",
    "    [\"0011\", \"01100\", \"10111\", \"11110\"],\n",
    "    [\"0100\", \"01001\", \"11001\", \"00001\"],\n",
    "    [\"0110\", \"10010\", \"11001\", \"10111\"],\n",
    "    [\"0001\", \"00000\", \"11010\", \"01001\"],\n",
    "\n",
    "    [\"1100\", \"00110\", \"01011\", \"01010\"],\n",
    "    [\"1111\", \"01001\", \"10100\", \"01101\"],\n",
    "    [\"1000\", \"01010\", \"01001\", \"01101\"],\n",
    "    [\"0101\", \"11101\", \"10010\", \"01001\"],\n",
    "    [\"0101\", \"00011\", \"00111\", \"01110\"],\n",
    "]\n",
    "\n",
    "for waxIdBinary in binaryWaxIdList:\n",
    "    waxId = format(int(\"\".join(waxIdBinary), 2), '05X')\n",
    "\n",
    "    query = {\n",
    "        \"waxId\": waxId\n",
    "    }\n",
    "\n",
    "    r = requests.post(f\"{adminApiUrl}/admin/fabricator/jobs\", headers=getAdminHeaders(), json=query)\n",
    "    \n",
    "    foundJobId = None\n",
    "\n",
    "    if r.status_code == 200:\n",
    "        jobs = r.json()[\"jobs\"]\n",
    "        if len(jobs) > 0:\n",
    "            foundJobId = jobs[0][\"id\"]\n",
    "    else:\n",
    "        print(r.status_code)\n",
    "        print(r.text)\n",
    "\n",
    "    if foundJobId:\n",
    "        print(\"FOUND IT: \" + waxId + \" URL: \" + f\"{config['BIGSCREEN_ARDA_URL']}/fabricator/job/{foundJobId}\")\n",
    "    else:\n",
    "        print(\"DID NOT FIND IT HOLY FUCK \" + waxId, waxIdBinary)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
