bwsamern-ohne_standortplaner/backend/check_assignments.js

36 lines
1.0 KiB
JavaScript

const { Client } = require('pg');
const client = new Client({
host: '87.106.21.21',
port: 5432,
user: 'enwelo_admin',
password: 'WX1t1cgP1qK09',
database: 'enwelo'
});
client.connect().then(async () => {
try {
const res = await client.query(`
SELECT
a."VNA", a."GNA", a."FSK",
z.projekt_id IS NOT NULL as is_assigned
FROM geodaten.flaecheneigentuemer_alkis a
LEFT JOIN geodaten.flaecheneigentuemer_alkis_zuweisung z ON a."FSK" = z.fsk
LIMIT 20
`);
console.table(res.rows);
const summary = await client.query(`
SELECT
count(*) as total,
count(z.fsk) as assigned
FROM geodaten.flaecheneigentuemer_alkis a
LEFT JOIN geodaten.flaecheneigentuemer_alkis_zuweisung z ON a."FSK" = z.fsk
`);
console.log("Summary:", summary.rows[0]);
} catch (e) {
console.error(e);
} finally {
client.end();
}
});