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
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- pb_data:/pb/pb_data
|
- pb_data:/pb/pb_data
|
||||||
# ports:
|
ports:
|
||||||
#- "4444:8090"
|
- "4444:8090"
|
||||||
nextjs:
|
nextjs:
|
||||||
build: ./frontend
|
build: ./frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
export const dynamic = 'force-dynamic';
|
export const dynamic = 'force-dynamic';
|
||||||
|
import { unstable_noStore as noStore } from 'next/cache';
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { pb, COUNTRY_LABELS, COUNTRY_FLAGS } from "@/lib/pb";
|
import { pb, COUNTRY_LABELS, COUNTRY_FLAGS } from "@/lib/pb";
|
||||||
|
|
||||||
async function getStats() {
|
async function getStats() {
|
||||||
|
noStore();
|
||||||
try {
|
try {
|
||||||
const [kz, diplo, gesehen] = await Promise.all([
|
const [kz, diplo, gesehen] = await Promise.all([
|
||||||
pb.collection("kennzeichen").getList(1, 1, { filter: "active=true" }),
|
pb.collection("kennzeichen").getList(1, 1, { filter: "active=true" }),
|
||||||
|
|
@ -20,6 +22,7 @@ async function getStats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getLasteSeen() {
|
async function getLasteSeen() {
|
||||||
|
noStore();
|
||||||
try {
|
try {
|
||||||
return pb.collection("gesehen").getList(1, 5, { sort: "-datum" });
|
return pb.collection("gesehen").getList(1, 5, { sort: "-datum" });
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
||||||
|
|
@ -385,13 +385,6 @@ def import_backup(pb, backup_path, db_path):
|
||||||
if land in ("global", "global2", "laender"):
|
if land in ("global", "global2", "laender"):
|
||||||
kz_code = normalize_diplo_code(kz_code)
|
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
|
# Kennzeichen-Namen aus Referenz holen
|
||||||
try:
|
try:
|
||||||
rcur.execute(f"SELECT ort FROM {land} WHERE id=?", (kennid,))
|
rcur.execute(f"SELECT ort FROM {land} WHERE id=?", (kennid,))
|
||||||
|
|
@ -400,6 +393,21 @@ def import_backup(pb, backup_path, db_path):
|
||||||
except:
|
except:
|
||||||
kz_name = ""
|
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", {
|
pb.create("gesehen", {
|
||||||
"kennzeichen_code": kz_code,
|
"kennzeichen_code": kz_code,
|
||||||
"kennzeichen_name": kz_name,
|
"kennzeichen_name": kz_name,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue