Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
martinantonmueller committed Jan 19, 2024
2 parents c3cefcd + 029ccde commit 3a0e4b6
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
<th>Ortstype</th>
<td>{% if object.kind.description %} {{ object.kind }} <small>{{ object.kind.description }}</small> {% else %} {{ object.kind }} {% endif %}</td>
</tr>
{% if object.start_date_written or object.end_date_written %}
<tr>
<th>von – bis</th>
<td>{% if object.start_date_written %}{{ object.start_date_written }}{% endif %}{% if object.end_date_written %} – {{ object.end_date_written }}{% endif %}</td>
</tr>
{% endif %}
</table>

{% endblock info-table %}
5 changes: 2 additions & 3 deletions dump_and_restore.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

pg_dump -d pmb -h localhost -p 5432 -U postgres -c -f pmb_dump.sql
pg_dump -d pmb_play -h localhost -p 5432 -U postgres -c -f pmb_play_dump.sql

pg_dump -d pmb -h localhost -p 5433 -U pmb -c -f pmb_dump.sql
psql -U postgres -d pmb < pmb_dump.sql
157 changes: 157 additions & 0 deletions issue__80_professions.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "7d1e0d0c",
"metadata": {},
"source": [
"# run 2024-01-19 on production server"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "2fe08400",
"metadata": {},
"outputs": [],
"source": [
"from tqdm import tqdm\n",
"from dumper.utils import gsheet_to_df"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2b4ee9e3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"200\n"
]
}
],
"source": [
"df = gsheet_to_df(\"1MnS_eJbPNLzXp4YkS5I9Xkhv2GVPbYtrFiQjJla5rJE\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "f47bcd68",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"1518it [01:10, 27.09it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1513\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"1567it [01:12, 21.47it/s]\n"
]
}
],
"source": [
"for i, row in tqdm(df.iterrows()):\n",
" try:\n",
" pl = ProfessionType.objects.get(id=row[\"id\"])\n",
" except:\n",
" print(i)\n",
" continue\n",
" name = row[\"name\"]\n",
" pl.name = name\n",
" pl.save()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f820cd7f",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"1567it [01:34, 16.66it/s] \n"
]
}
],
"source": [
"delete_us = []\n",
"for i, row in tqdm(df.iterrows()):\n",
" if isinstance(row[\"duplicates\"], str):\n",
" pl = ProfessionType.objects.get(id=row[\"id\"])\n",
" ids = [int(x) for x in row[\"duplicates\"].split('|')]\n",
" persons = Person.objects.filter(profession__in=ids)\n",
" for y in persons:\n",
" y.profession.add(pl)\n",
" for x in ids:\n",
" try:\n",
" to_del = ProfessionType.objects.get(id=x)\n",
" except:\n",
" print(f\"cant find {x}\")\n",
" continue\n",
" delete_us.append(to_del) \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "fe06fca6",
"metadata": {},
"outputs": [],
"source": [
"for x in delete_us:\n",
" try:\n",
" x.delete()\n",
" except:\n",
" print(x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "85c6f39d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Django Shell-Plus",
"language": "python",
"name": "django_extensions"
},
"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.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 3a0e4b6

Please sign in to comment.