From 502817a38cf42246880a532264b2158060a56f61 Mon Sep 17 00:00:00 2001 From: Stephan Kulla Date: Thu, 9 Nov 2023 21:05:49 +0100 Subject: [PATCH] Add src/2023/2023-11-09-inconsitencies-in-the-database.ipynb --- ...11-09-inconsitencies-in-the-database.ipynb | 978 ++++++++++++++++++ 1 file changed, 978 insertions(+) create mode 100644 src/2023/2023-11-09-inconsitencies-in-the-database.ipynb diff --git a/src/2023/2023-11-09-inconsitencies-in-the-database.ipynb b/src/2023/2023-11-09-inconsitencies-in-the-database.ipynb new file mode 100644 index 0000000..7eeed0b --- /dev/null +++ b/src/2023/2023-11-09-inconsitencies-in-the-database.ipynb @@ -0,0 +1,978 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "cebb172f-ebcb-4dbf-8958-107c1b38b2c3", + "metadata": {}, + "source": [ + "# Helper functions" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "a5e2a8c7-ecc6-4c28-87d0-59236627411a", + "metadata": {}, + "outputs": [], + "source": [ + "from IPython.display import display, Markdown, HTML\n", + "\n", + "from sqlalchemy import create_engine\n", + "from sqlalchemy import text\n", + "\n", + "engine_local = create_engine(\n", + " f\"mysql+mysqlconnector://root:secret@localhost:3306/serlo?charset=latin1\"\n", + ")\n", + "\n", + "class MySQLSession:\n", + " def __init__(self, engine):\n", + " self.engine = engine\n", + " \n", + " def __enter__(self):\n", + " self.connection = self.engine.connect()\n", + " return self\n", + " \n", + " def __exit__(self, *args):\n", + " self.connection.commit()\n", + " self.connection.close()\n", + " \n", + " def execute(self, statement, **kwargs):\n", + " return self.connection.execute(text(statement), kwargs)\n", + "\n", + " def query(self, statement, **kwargs):\n", + " return list(self.execute(statement, **kwargs))\n", + " \n", + " def begin(self):\n", + " return self.connection.begin()\n", + " \n", + "with MySQLSession(engine_local) as session:\n", + " pass" + ] + }, + { + "cell_type": "markdown", + "id": "5fa1e717-e176-436c-8aa8-d88a071ca615", + "metadata": {}, + "source": [ + "# Uuids in the `uuid` which do not have a corresponding entry in another table" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "352dd822-e5ff-4ae5-aeb3-072023a67243", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "### Uuids of type `comment` not having a appropriate entry in `comment`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
counttrasheddiscriminator
06900comment
\n", + "
" + ], + "text/plain": [ + " count trashed discriminator\n", + "0 690 0 comment" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "### Uuids of type `entity` not having a appropriate entry in `entity`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
counttrasheddiscriminator
\n", + "
" + ], + "text/plain": [ + "Empty DataFrame\n", + "Columns: [count, trashed, discriminator]\n", + "Index: []" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "### Uuids of type `entityRevision` not having a appropriate entry in `entity_revision`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
counttrasheddiscriminator
060470entityRevision
1481entityRevision
\n", + "
" + ], + "text/plain": [ + " count trashed discriminator\n", + "0 6047 0 entityRevision\n", + "1 48 1 entityRevision" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "### Uuids of type `page` not having a appropriate entry in `page_repository`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
counttrasheddiscriminator
\n", + "
" + ], + "text/plain": [ + "Empty DataFrame\n", + "Columns: [count, trashed, discriminator]\n", + "Index: []" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "### Uuids of type `pageRevision` not having a appropriate entry in `page_revision`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
counttrasheddiscriminator
022000pageRevision
\n", + "
" + ], + "text/plain": [ + " count trashed discriminator\n", + "0 2200 0 pageRevision" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "### Uuids of type `taxonomyTerm` not having a appropriate entry in `term_taxonomy`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
counttrasheddiscriminator
02630taxonomyTerm
\n", + "
" + ], + "text/plain": [ + " count trashed discriminator\n", + "0 263 0 taxonomyTerm" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "### Uuids of type `user` not having a appropriate entry in `user`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
counttrasheddiscriminator
\n", + "
" + ], + "text/plain": [ + "Empty DataFrame\n", + "Columns: [count, trashed, discriminator]\n", + "Index: []" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import pandas as pd\n", + "\n", + "tables_for_uuid_types = {\n", + " \"comment\": \"comment\",\n", + " \"entity\": \"entity\",\n", + " \"entityRevision\": \"entity_revision\",\n", + " \"page\": \"page_repository\",\n", + " \"pageRevision\": \"page_revision\",\n", + " \"taxonomyTerm\": \"term_taxonomy\",\n", + " \"user\": \"user\"\n", + "}\n", + "\n", + "def select_singletons(rows):\n", + " return [row[0] for row in rows]\n", + "\n", + "with MySQLSession(engine_local) as session:\n", + " discriminators = select_singletons(session.query(\"\"\"\n", + " select distinct discriminator from uuid\n", + " \"\"\"))\n", + "\n", + " for discriminator in discriminators:\n", + " if discriminator in tables_for_uuid_types:\n", + " table = tables_for_uuid_types[discriminator]\n", + " \n", + " display(Markdown(f\"### Uuids of type `{discriminator}` not having a appropriate entry in `{table}`\"))\n", + " \n", + " display(pd.read_sql_query(f\"\"\"\n", + " select count(*) as count, uuid.trashed, discriminator from uuid left join {table} on {table}.id = uuid.id where discriminator = \"{discriminator}\" and {table}.id is null group by trashed\n", + " \"\"\", session.connection))" + ] + }, + { + "cell_type": "markdown", + "id": "d103fddb-5e63-44ea-8684-3e66e3bb88bc", + "metadata": {}, + "source": [ + "# Child entities not having a parent" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "243bb95c-7bff-427f-9886-49779ef7e80a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
countnametrashed
0172course-page0
1553grouped-text-exercise0
21grouped-text-exercise1
3674text-solution0
\n", + "
" + ], + "text/plain": [ + " count name trashed\n", + "0 172 course-page 0\n", + "1 553 grouped-text-exercise 0\n", + "2 1 grouped-text-exercise 1\n", + "3 674 text-solution 0" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "with MySQLSession(engine_local) as session:\n", + " display(pd.read_sql_query(\"\"\"\n", + " select\n", + " count(entity.id) as count, type.name, uuid.trashed\n", + " from entity\n", + " join uuid on uuid.id = entity.id\n", + " join type on entity.type_id = type.id\n", + " left join entity_link on entity_link.child_id = entity.id\n", + " where\n", + " type.name in (\"grouped-text-exercise\", \"text-solution\", \"course-page\")\n", + " and entity_link.child_id is null\n", + " group by type.name, uuid.trashed\n", + " \"\"\", session.connection))" + ] + }, + { + "cell_type": "markdown", + "id": "15d89313-4b0d-40ec-bc2d-8f842faad21c", + "metadata": {}, + "source": [ + "# Examples" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "c54060cc-d636-454f-951e-c5f431f41e76", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idnametrashedsubdomaindate_creatednr_revisionsdate_last_revisionparameters
02739grouped-text-exercise0de2014-03-01 20:58:46302022-04-25 09:30:03{\"changes\": \"Grundwissen verlinkt und Lösungsstrategie beschrieben.\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac x{x^2+4}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\\\":\\\"f(x)\"}
12743grouped-text-exercise0de2014-03-01 20:59:07122022-04-25 15:10:39{\"changes\": \"Konvertiert, Rechtschreibfehler korrigiert und Gleichungsumfornungen in Plugins gepackt.\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{x^2}{x^2+16}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\\\":\\\"\"}
22747grouped-text-exercise0de2014-03-01 20:59:20162022-05-09 16:32:26{\"changes\": \"Konvertiert\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{x}{x^2-4}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\\\":\\\"f(x\"}
32751grouped-text-exercise0de2014-03-01 20:59:34142022-05-09 16:32:54{\"changes\": \"Im neuen Editor gespeichert\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{x^2}{x^2-16\\\\\\\\ }\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\"}
42755grouped-text-exercise0de2014-03-01 20:59:47142022-05-13 10:30:02{\"changes\": \"Bei Symmetrieverhalten 2 mal = auf der rechten Gleichungsseite gelöscht\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{x^2}{(x-0,5)^2}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\"}
52759grouped-text-exercise0de2014-03-01 21:00:02142022-05-13 11:06:50{\"changes\": \"Bei den Gleichungen mehrfach = auf der rechten Gleichungsseite entfernt\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{x^3}{2(x^2-1)}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\\\"\"}
62763grouped-text-exercise0de2014-03-01 21:00:21202022-05-13 11:27:08{\"changes\": \"in 2.Ableitung = auf der rechten Gleichungsseite entfernt\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{2x^2}{2x-1}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\\\":\\\"f\"}
72889text-solution0de2014-03-01 21:03:1882014-09-03 17:21:26{\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"h\\\",\\\"level\\\":3,\\\"children\\\":[{\\\"type\\\":\\\"a\\\",\\\"href\\\":\\\"/1505\\\",\\\"children\\\":[{\\\"text\\\":\\\"Ereignisse berechnen\\\"}]}]}]},{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\"\"}
82893text-solution0de2014-03-01 21:03:2242014-09-03 17:02:45{\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"h\\\",\\\"level\\\":3,\\\"children\\\":[{\\\"type\\\":\\\"a\\\",\\\"href\\\":\\\"/1501\\\",\\\"children\\\":[{\\\"text\\\":\\\"Ergebnisraum\\\"}]},{\\\"text\\\":\\\" bestimmen\\\"}]}]},{\\\"plugin\\\":\\\"text\\\",\\\"state\"}
92899text-solution0de2014-03-01 21:03:2342014-09-03 16:42:33{\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"h\\\",\\\"level\\\":2,\\\"children\\\":[{\\\"text\\\":\\\"Ereignisse\\\"}]}]},{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"a\\\",\\\"href\\\":\\\"/1505\\\",\\\"children\\\":\"}
102903grouped-text-exercise0de2014-03-01 21:03:2382014-09-03 15:21:36{\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"A und B, aber nicht C\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"str\"}
112905grouped-text-exercise0de2014-03-01 21:03:2362014-09-03 15:24:50{\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Alle drei\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\":{\\\"plu\"}
122907grouped-text-exercise0de2014-03-01 21:03:2362014-09-03 15:23:40{\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Nur A\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\":{\\\"plugin\\\"\"}
132909grouped-text-exercise0de2014-03-01 21:03:2342014-09-03 15:32:39{\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Höchstens eines\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\"\"}
142911grouped-text-exercise0de2014-03-01 21:03:23102023-09-14 18:42:38{\"changes\": \"fix formula\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Mindestens eines\\\"}]}],\\\"id\\\":\\\"c81ddb84-e39e-4717-99e4-cb6484161d76\\\"}],\\\"id\\\":\\\"6\"}
152913grouped-text-exercise0de2014-03-01 21:03:2382023-09-14 19:37:52{\"changes\": \"formula\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Höchstens zwei\\\"}]}],\\\"id\\\":\\\"1941dce7-9735-4d41-9bf1-74bbc05bc611\\\"}],\\\"id\\\":\\\"bfd\"}
162915grouped-text-exercise0de2014-03-01 21:03:2382023-09-14 19:04:00{\"changes\": \"fix formulas\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Mindestens zwei\\\"}]}],\\\"id\\\":\\\"bf93702f-7734-4b42-9f18-a091a4b63793\\\"}],\\\"id\\\":\\\"2e\"}
172917grouped-text-exercise0de2014-03-01 21:03:2342014-09-03 15:20:04{\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Genau eines\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\":{\\\"p\"}
182919grouped-text-exercise0de2014-03-01 21:03:2342014-09-03 16:08:47{\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Genau zwei\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\":{\\\"pl\"}
192921grouped-text-exercise0de2014-03-01 21:03:2362014-09-03 15:25:49{\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Keines\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\":{\\\"plugin\"}
\n", + "
" + ], + "text/plain": [ + " id name trashed subdomain date_created \\\n", + "0 2739 grouped-text-exercise 0 de 2014-03-01 20:58:46 \n", + "1 2743 grouped-text-exercise 0 de 2014-03-01 20:59:07 \n", + "2 2747 grouped-text-exercise 0 de 2014-03-01 20:59:20 \n", + "3 2751 grouped-text-exercise 0 de 2014-03-01 20:59:34 \n", + "4 2755 grouped-text-exercise 0 de 2014-03-01 20:59:47 \n", + "5 2759 grouped-text-exercise 0 de 2014-03-01 21:00:02 \n", + "6 2763 grouped-text-exercise 0 de 2014-03-01 21:00:21 \n", + "7 2889 text-solution 0 de 2014-03-01 21:03:18 \n", + "8 2893 text-solution 0 de 2014-03-01 21:03:22 \n", + "9 2899 text-solution 0 de 2014-03-01 21:03:23 \n", + "10 2903 grouped-text-exercise 0 de 2014-03-01 21:03:23 \n", + "11 2905 grouped-text-exercise 0 de 2014-03-01 21:03:23 \n", + "12 2907 grouped-text-exercise 0 de 2014-03-01 21:03:23 \n", + "13 2909 grouped-text-exercise 0 de 2014-03-01 21:03:23 \n", + "14 2911 grouped-text-exercise 0 de 2014-03-01 21:03:23 \n", + "15 2913 grouped-text-exercise 0 de 2014-03-01 21:03:23 \n", + "16 2915 grouped-text-exercise 0 de 2014-03-01 21:03:23 \n", + "17 2917 grouped-text-exercise 0 de 2014-03-01 21:03:23 \n", + "18 2919 grouped-text-exercise 0 de 2014-03-01 21:03:23 \n", + "19 2921 grouped-text-exercise 0 de 2014-03-01 21:03:23 \n", + "\n", + " nr_revisions date_last_revision \\\n", + "0 30 2022-04-25 09:30:03 \n", + "1 12 2022-04-25 15:10:39 \n", + "2 16 2022-05-09 16:32:26 \n", + "3 14 2022-05-09 16:32:54 \n", + "4 14 2022-05-13 10:30:02 \n", + "5 14 2022-05-13 11:06:50 \n", + "6 20 2022-05-13 11:27:08 \n", + "7 8 2014-09-03 17:21:26 \n", + "8 4 2014-09-03 17:02:45 \n", + "9 4 2014-09-03 16:42:33 \n", + "10 8 2014-09-03 15:21:36 \n", + "11 6 2014-09-03 15:24:50 \n", + "12 6 2014-09-03 15:23:40 \n", + "13 4 2014-09-03 15:32:39 \n", + "14 10 2023-09-14 18:42:38 \n", + "15 8 2023-09-14 19:37:52 \n", + "16 8 2023-09-14 19:04:00 \n", + "17 4 2014-09-03 15:20:04 \n", + "18 4 2014-09-03 16:08:47 \n", + "19 6 2014-09-03 15:25:49 \n", + "\n", + " parameters \n", + "0 {\"changes\": \"Grundwissen verlinkt und Lösungsstrategie beschrieben.\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac x{x^2+4}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\\\":\\\"f(x)\"} \n", + "1 {\"changes\": \"Konvertiert, Rechtschreibfehler korrigiert und Gleichungsumfornungen in Plugins gepackt.\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{x^2}{x^2+16}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\\\":\\\"\"} \n", + "2 {\"changes\": \"Konvertiert\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{x}{x^2-4}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\\\":\\\"f(x\"} \n", + "3 {\"changes\": \"Im neuen Editor gespeichert\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{x^2}{x^2-16\\\\\\\\ }\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\"} \n", + "4 {\"changes\": \"Bei Symmetrieverhalten 2 mal = auf der rechten Gleichungsseite gelöscht\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{x^2}{(x-0,5)^2}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\"} \n", + "5 {\"changes\": \"Bei den Gleichungen mehrfach = auf der rechten Gleichungsseite entfernt\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{x^3}{2(x^2-1)}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\\\"\"} \n", + "6 {\"changes\": \"in 2.Ableitung = auf der rechten Gleichungsseite entfernt\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"math\\\",\\\"src\\\":\\\"f(x)=\\\\\\\\frac{2x^2}{2x-1}\\\",\\\"inline\\\":false,\\\"children\\\":[{\\\"text\\\":\\\"f\"} \n", + "7 {\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"h\\\",\\\"level\\\":3,\\\"children\\\":[{\\\"type\\\":\\\"a\\\",\\\"href\\\":\\\"/1505\\\",\\\"children\\\":[{\\\"text\\\":\\\"Ereignisse berechnen\\\"}]}]}]},{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\"\"} \n", + "8 {\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"h\\\",\\\"level\\\":3,\\\"children\\\":[{\\\"type\\\":\\\"a\\\",\\\"href\\\":\\\"/1501\\\",\\\"children\\\":[{\\\"text\\\":\\\"Ergebnisraum\\\"}]},{\\\"text\\\":\\\" bestimmen\\\"}]}]},{\\\"plugin\\\":\\\"text\\\",\\\"state\"} \n", + "9 {\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"h\\\",\\\"level\\\":2,\\\"children\\\":[{\\\"text\\\":\\\"Ereignisse\\\"}]}]},{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"type\\\":\\\"a\\\",\\\"href\\\":\\\"/1505\\\",\\\"children\\\":\"} \n", + "10 {\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"A und B, aber nicht C\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"str\"} \n", + "11 {\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Alle drei\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\":{\\\"plu\"} \n", + "12 {\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Nur A\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\":{\\\"plugin\\\"\"} \n", + "13 {\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Höchstens eines\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\"\"} \n", + "14 {\"changes\": \"fix formula\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Mindestens eines\\\"}]}],\\\"id\\\":\\\"c81ddb84-e39e-4717-99e4-cb6484161d76\\\"}],\\\"id\\\":\\\"6\"} \n", + "15 {\"changes\": \"formula\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Höchstens zwei\\\"}]}],\\\"id\\\":\\\"1941dce7-9735-4d41-9bf1-74bbc05bc611\\\"}],\\\"id\\\":\\\"bfd\"} \n", + "16 {\"changes\": \"fix formulas\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Mindestens zwei\\\"}]}],\\\"id\\\":\\\"bf93702f-7734-4b42-9f18-a091a4b63793\\\"}],\\\"id\\\":\\\"2e\"} \n", + "17 {\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Genau eines\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\":{\\\"p\"} \n", + "18 {\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Genau zwei\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\":{\\\"pl\"} \n", + "19 {\"changes\": \"\", \"content\": \"{\\\"plugin\\\":\\\"exercise\\\",\\\"state\\\":{\\\"content\\\":{\\\"plugin\\\":\\\"rows\\\",\\\"state\\\":[{\\\"plugin\\\":\\\"text\\\",\\\"state\\\":[{\\\"type\\\":\\\"p\\\",\\\"children\\\":[{\\\"text\\\":\\\"Keines\\\"}]}]}]},\\\"solution\\\":{\\\"plugin\\\":\\\"solution\\\",\\\"state\\\":{\\\"strategy\\\":{\\\"plugin\"} " + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "pd.set_option('display.width', None)\n", + "pd.set_option('display.max_colwidth', 500)\n", + "\n", + "with MySQLSession(engine_local) as session:\n", + " display(pd.read_sql_query(\"\"\"\n", + " select\n", + " entity.id, type.name, uuid.trashed, instance.subdomain,\n", + " entity.date as date_created,\n", + " count(entity_revision.id) as nr_revisions,\n", + " max(entity_revision.date) as date_last_revision,\n", + " JSON_OBJECTAGG(entity_revision_field.field, LEFT(entity_revision_field.value, 200)) as parameters \n", + " from entity\n", + " join instance on entity.instance_id = instance.id\n", + " join entity_revision on entity_revision.repository_id = entity.id\n", + " join entity_revision_field on entity_revision_field.entity_revision_id = entity.current_revision_id\n", + " join uuid on uuid.id = entity.id\n", + " join type on entity.type_id = type.id\n", + " left join entity_link on entity_link.child_id = entity.id\n", + " where\n", + " type.name in (\"grouped-text-exercise\", \"text-solution\", \"course-page\")\n", + " and entity_link.child_id is null\n", + " group by entity.id\n", + " limit 20\n", + " \"\"\", session.connection))" + ] + } + ], + "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.9.1" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}