Mirror Nordex geometries and add version marker v1.0.2
Deploy Bürgerwind / deploy (push) Successful in 16s Details

This commit is contained in:
Johannes Baumeister 2026-05-12 13:15:24 +02:00
parent fce2e6e748
commit 3ef8e1d017
8 changed files with 188 additions and 1 deletions

View File

@ -0,0 +1,31 @@
const { Client } = require('pg');
async function check() {
const client = new Client({
host: '87.106.21.21',
port: 5432,
user: 'enwelo_admin',
password: 'WX1t1cgP1qK09',
database: 'enwelo'
});
try {
await client.connect();
const res = await client.query(`
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_schema = 'geodaten' AND table_name = 'flaecheneigentuemer_alkis'
`);
console.log("Columns in geodaten.flaecheneigentuemer_alkis:");
console.log(res.rows);
const sample = await client.query('SELECT * FROM geodaten.flaecheneigentuemer_alkis LIMIT 1');
console.log("\nSample row:");
console.log(sample.rows[0]);
} catch (e) {
console.error(e);
} finally {
await client.end();
}
}
check();

View File

@ -0,0 +1,27 @@
const { Client } = require('pg');
async function check() {
const client = new Client({
host: '87.106.21.21',
port: 5432,
user: 'enwelo_admin',
password: 'WX1t1cgP1qK09',
database: 'enwelo'
});
try {
await client.connect();
const res = await client.query(`
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_schema = 'geodaten' AND table_name = 'flaecheneigentuemer_alkis2'
`);
console.log("Columns in geodaten.flaecheneigentuemer_alkis2:");
console.log(res.rows.map(r => r.column_name).join(', '));
} catch (e) {
console.error(e);
} finally {
await client.end();
}
}
check();

23
backend/check_wea.js Normal file
View File

@ -0,0 +1,23 @@
const { Client } = require('pg');
async function check() {
const client = new Client({
host: '87.106.21.21',
port: 5432,
user: 'enwelo_admin',
password: 'WX1t1cgP1qK09',
database: 'enwelo'
});
try {
await client.connect();
const res = await client.query("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'geodaten' AND table_name = 'wea_standorte'");
console.log("Columns in geodaten.wea_standorte:");
console.log(res.rows);
} catch (e) {
console.error(e);
} finally {
await client.end();
}
}
check();

34
backend/fix_db.js Normal file
View File

@ -0,0 +1,34 @@
const { Client } = require('pg');
async function fix() {
const client = new Client({
host: '87.106.21.21',
port: 5432,
user: 'enwelo_admin',
password: 'WX1t1cgP1qK09',
database: 'enwelo'
});
try {
await client.connect();
// 1. Rename existing GNA if it exists
await client.query('ALTER TABLE geodaten.flaecheneigentuemer_alkis RENAME COLUMN "GNA" TO "OLD_GNA"');
console.log("Renamed GNA to OLD_GNA");
// 2. Rename NOF to GNA
await client.query('ALTER TABLE geodaten.flaecheneigentuemer_alkis RENAME COLUMN "NOF" TO "GNA"');
console.log("Renamed NOF to GNA");
// 3. Add status and notiz
await client.query('ALTER TABLE geodaten.flaecheneigentuemer_alkis ADD COLUMN IF NOT EXISTS status text');
await client.query('ALTER TABLE geodaten.flaecheneigentuemer_alkis ADD COLUMN IF NOT EXISTS notiz text');
console.log("Added status and notiz columns");
} catch (e) {
console.error(e);
} finally {
await client.end();
}
}
fix();

48
backend/fix_view.js Normal file
View File

@ -0,0 +1,48 @@
const { Client } = require('pg');
async function fixView() {
const client = new Client({
host: '87.106.21.21',
port: 5432,
user: 'enwelo_admin',
password: 'WX1t1cgP1qK09',
database: 'enwelo'
});
try {
await client.connect();
const createViewSql = `
CREATE OR REPLACE VIEW geodaten.v_projekt_sicherung AS
SELECT az.projekt_id,
p.name AS projekt_name,
a.id AS alkis_id,
a."FSK" AS fsk,
a."GNA" AS nachname,
a."VNA" AS vorname,
a.bemerkung AS nof_zusatz,
COALESCE(s.status, 'Unbekannt'::text) AS aktueller_status,
s.datum AS status_datum,
r.farbe_hex,
a.geom
FROM geodaten.flaecheneigentuemer_alkis_zuweisung az
JOIN geodaten.flaecheneigentuemer_alkis a ON az.fsk = a."FSK"
JOIN geodaten.projekte p ON az.projekt_id = p.id
LEFT JOIN LATERAL ( SELECT flaecheneigentuemer_status.status,
flaecheneigentuemer_status.datum
FROM geodaten.flaecheneigentuemer_status
WHERE flaecheneigentuemer_status.fsk = az.fsk AND flaecheneigentuemer_status.projekt_id = az.projekt_id
ORDER BY flaecheneigentuemer_status.datum DESC
LIMIT 1) s ON true
LEFT JOIN geodaten.ref_sicherungsstatus r ON s.status = r.status_name;
`;
await client.query(createViewSql);
console.log("View recreated successfully.");
} catch (e) {
console.error(e);
} finally {
await client.end();
}
}
fixView();

View File

@ -0,0 +1,24 @@
const { Client } = require('pg');
const client = new Client({ host: '87.106.21.21', port: 5432, user: 'enwelo_admin', password: 'WX1t1cgP1qK09', database: 'enwelo' });
async function resolveProjectId(client, input) {
if (!input) return null;
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
if (uuidRegex.test(input)) return input;
const normalized = input.toLowerCase().replace(/[-_]/g, '');
const res = await client.query('SELECT id FROM geodaten.projekte WHERE LOWER(REPLACE(REPLACE(name, \'-\', \'\'), \'_\', \'\')) = $1', [normalized]);
return res.rows.length > 0 ? res.rows[0].id : null;
}
client.connect().then(async () => {
try {
const pid = await resolveProjectId(client, 'BWSamern-Ohne');
console.log('Resolved PID:', pid);
const res = await client.query('SELECT vorname, nachname, aktueller_status as status FROM geodaten.v_projekt_sicherung WHERE projekt_id = $1 LIMIT 5', [pid]);
console.table(res.rows);
} catch (e) {
console.error(e);
} finally {
client.end();
}
});

0
enwelo_db.session.sql Normal file
View File

View File

@ -142,7 +142,7 @@
<div id="statusInfo" <div id="statusInfo"
style="margin-top: auto; padding-top: 20px; font-size: 0.8rem; color: var(--text-dim);"> style="margin-top: auto; padding-top: 20px; font-size: 0.8rem; color: var(--text-dim);">
Bereit. Bereit. (v1.0.2 - Mirrored Nordex)
</div> </div>
</div> </div>
</aside> </aside>