import script for backups updated
This commit is contained in:
parent
52d76afed6
commit
338f04fda3
4 changed files with 20 additions and 16 deletions
|
|
@ -1,7 +0,0 @@
|
|||
# PocketBase Admin-Zugangsdaten
|
||||
# Kopieren nach .env und ausfüllen:
|
||||
# cp .env.example .env
|
||||
|
||||
PB_URL=http://localhost:4444
|
||||
PB_EMAIL=admin@example.com
|
||||
PB_PASSWORD=
|
||||
|
|
@ -4,8 +4,8 @@ services:
|
|||
restart: unless-stopped
|
||||
volumes:
|
||||
- pb_data:/pb/pb_data
|
||||
# ports:
|
||||
#- "4444:8090"
|
||||
ports:
|
||||
- "4444:8090"
|
||||
nextjs:
|
||||
build: ./frontend
|
||||
restart: unless-stopped
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
export const dynamic = 'force-dynamic';
|
||||
import { unstable_noStore as noStore } from 'next/cache';
|
||||
import Link from "next/link";
|
||||
import { pb, COUNTRY_LABELS, COUNTRY_FLAGS } from "@/lib/pb";
|
||||
|
||||
async function getStats() {
|
||||
noStore();
|
||||
try {
|
||||
const [kz, diplo, gesehen] = await Promise.all([
|
||||
pb.collection("kennzeichen").getList(1, 1, { filter: "active=true" }),
|
||||
|
|
@ -20,6 +22,7 @@ async function getStats() {
|
|||
}
|
||||
|
||||
async function getLasteSeen() {
|
||||
noStore();
|
||||
try {
|
||||
return pb.collection("gesehen").getList(1, 5, { sort: "-datum" });
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -385,13 +385,6 @@ def import_backup(pb, backup_path, db_path):
|
|||
if land in ("global", "global2", "laender"):
|
||||
kz_code = normalize_diplo_code(kz_code)
|
||||
|
||||
# Duplikat prüfen
|
||||
existing = pb.find_record("gesehen",
|
||||
f'kennzeichen_code="{kz_code}" && land="{folder}"')
|
||||
if existing:
|
||||
skipped += 1
|
||||
continue
|
||||
|
||||
# Kennzeichen-Namen aus Referenz holen
|
||||
try:
|
||||
rcur.execute(f"SELECT ort FROM {land} WHERE id=?", (kennid,))
|
||||
|
|
@ -400,6 +393,21 @@ def import_backup(pb, backup_path, db_path):
|
|||
except:
|
||||
kz_name = ""
|
||||
|
||||
existing = pb.find_record("gesehen",
|
||||
f'kennzeichen_code="{kz_code}" && land="{folder}"')
|
||||
if existing:
|
||||
# Datum aktualisieren wenn neue Sichtung neuer ist
|
||||
if datum_iso > (existing.get("datum") or ""):
|
||||
requests.patch(
|
||||
f"{pb.url}/api/collections/gesehen/records/{existing['id']}",
|
||||
headers=pb.h(),
|
||||
json={"datum": datum_iso},
|
||||
)
|
||||
imported += 1
|
||||
else:
|
||||
skipped += 1
|
||||
continue
|
||||
|
||||
pb.create("gesehen", {
|
||||
"kennzeichen_code": kz_code,
|
||||
"kennzeichen_name": kz_name,
|
||||
|
|
|
|||
Loading…
Reference in a new issue