const { PrismaClient } = require("@prisma/client");
const p = new PrismaClient({
  datasourceUrl:
    "postgresql://architools_user:stictMyFon34!_gonY@10.10.10.166:5432/architools_db?schema=public",
});

(async () => {
  const features = await p.$queryRawUnsafe(`
    SELECT "layerId", siruta, "geometrySource", COUNT(*)::int as nr 
    FROM "GisFeature" 
    GROUP BY "layerId", siruta, "geometrySource" 
    ORDER BY "layerId", siruta, "geometrySource"
  `);
  console.log("=== GisFeature ===");
  console.table(features);

  const syncs = await p.$queryRawUnsafe(`
    SELECT "layerId", siruta, status, COUNT(*)::int as nr 
    FROM "GisSyncRun" 
    GROUP BY "layerId", siruta, status 
    ORDER BY "layerId", siruta
  `);
  console.log("=== GisSyncRun ===");
  console.table(syncs);

  const uats = await p.$queryRawUnsafe(`
    SELECT siruta, name, county, "workspacePk" 
    FROM "GisUat" 
    WHERE "workspacePk" IS NOT NULL AND "workspacePk" > 0
    LIMIT 20
  `);
  console.log("=== GisUat (with workspacePk) ===");
  console.table(uats);

  await p.$disconnect();
})();
