{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ddc1f0a0-a0ac-4f82-871d-640b3cf54557",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from database import connect as connect_database\n",
    "from classes import Tweet\n",
    "\n",
    "db = connect_database()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e7180544-f279-416f-bd45-8d2646ea1c7e",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "data = db.find_one({'account':'@Maersk'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a5f263e4-5fd1-4581-a4ef-cc4089becf23",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['_id', 'account', 'url', 'time', 'text', 'images', 'video'])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "625ab1f0-09ea-45a8-93a6-5d0cf58cddf6",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "tweet = Tweet.parse_obj(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d5040978-1f43-4380-8cc7-5fca8d181dea",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'@Maersk'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tweet.account"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "d3b66f4b-5fe4-477b-8dfd-3ebe0947dbb3",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"A spotless deck before delivery\\nSusan Mærsk was built by Odense Steel Shipyard in 1954 and a final inspection of the ship takes place before delivery. The ship was deployed on The Far East service - the company's first liner service initiated in 1928.\\n\\n#Maerskheritage #Maersk\""
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tweet.text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "23d18001-ca89-4c7d-b090-c04ede888fe5",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(tweet.images)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "bcd3378f-992b-4abf-8761-1e24aa55f9ac",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 351952 characters]",
      "text/plain": [
       "<PIL.PngImagePlugin.PngImageFile image mode=RGB size=680x466>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tweet.images[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "e7eb12ba-bf67-4dba-b0bd-75ce40bc11bc",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 532828 characters]",
      "text/plain": [
       "<PIL.PngImagePlugin.PngImageFile image mode=RGB size=680x515>"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tweet.images[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "b431e0e6-1536-4e56-b590-dadb77578613",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 510100 characters]",
      "text/plain": [
       "<PIL.PngImagePlugin.PngImageFile image mode=RGB size=680x515>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tweet.images[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "5d1560a0-d3fc-445f-9c45-e7fa0f53bd08",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 475848 characters]",
      "text/plain": [
       "<PIL.PngImagePlugin.PngImageFile image mode=RGB size=680x515>"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tweet.images[3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "f764cef5-2f6f-4289-afde-b944a14c766a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5190"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "db.count_documents({'account':'@Maersk'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "296b1527-4dc6-4e05-8833-e2e1feea8258",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9abdb991-fc9f-4a60-b1ad-fb29294aeda2",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
