This commit is contained in:
25
api/_tmp_find_contacts.php
Normal file
25
api/_tmp_find_contacts.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
$c = pg_connect("host=127.0.0.1 port=5432 dbname=adx_system user=admin password=admin123");
|
||||
|
||||
// Find all contacts-like tables
|
||||
$r = pg_query($c, "SELECT table_schema, table_name FROM information_schema.tables WHERE table_name ILIKE '%contact%' ORDER BY 1,2");
|
||||
echo "Contact tables:\n";
|
||||
$tables = [];
|
||||
while($row = pg_fetch_row($r)) {
|
||||
$tables[] = "$row[0].$row[1]";
|
||||
echo " $row[0].$row[1]\n";
|
||||
}
|
||||
|
||||
echo "\nRow counts:\n";
|
||||
foreach ($tables as $t) {
|
||||
$r = @pg_query($c, "SELECT COUNT(*) FROM $t");
|
||||
if ($r) {
|
||||
$n = pg_fetch_row($r)[0];
|
||||
echo " $t = $n\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Find which table has 'orphans_contacts' ref in code or KPI
|
||||
$r = pg_query($c, "SELECT table_schema, table_name FROM information_schema.columns WHERE column_name = 'company_id' LIMIT 10");
|
||||
echo "\nTables with company_id column:\n";
|
||||
while($row = pg_fetch_row($r)) echo " $row[0].$row[1]\n";
|
||||
11
api/_tmp_kpi_check.php
Normal file
11
api/_tmp_kpi_check.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
// Find which DB the KPI feeder uses
|
||||
$c = pg_connect("host=127.0.0.1 port=5432 dbname=adx_system user=admin password=admin123");
|
||||
$r = pg_query($c, "SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT LIKE 'pg_%' AND schema_name != 'information_schema'");
|
||||
echo "Schemas adx_system:\n";
|
||||
while($row = pg_fetch_row($r)) echo " " . $row[0] . "\n";
|
||||
|
||||
// List all tables
|
||||
$r = pg_query($c, "SELECT table_schema, table_name FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_schema NOT IN ('pg_catalog','information_schema') LIMIT 30");
|
||||
echo "\nTables:\n";
|
||||
while($row = pg_fetch_row($r)) echo " $row[0].$row[1]\n";
|
||||
12
api/_tmp_s95_orph.php
Normal file
12
api/_tmp_s95_orph.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// Run on S95 via sentinel
|
||||
$cmd = 'sudo -u postgres psql -d admin -tAc "SELECT COUNT(*) FROM crm.contacts WHERE company_id IS NULL"';
|
||||
echo "Cmd: $cmd\n";
|
||||
$ch = curl_init("https://wevads.weval-consulting.com/api/sentinel-brain.php");
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(["action"=>"exec","cmd"=>$cmd]));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
$r = curl_exec($ch);
|
||||
echo "Response: $r\n";
|
||||
Reference in New Issue
Block a user