- New caching_custom_backfill_jobs and caching_custom_backfill_batches tables - Admin API (POST create/cancel, GET list) at admin/api/custom_backfill.php - Admin UI form with preset buttons and job status table on Backfill page - Caching daemon module (custom_backfill.c) processes jobs independently - pg_inbox functions for job/batch claim, progress update, and cancel - Three batch modes: author-batched, id-batched, time-window scan - Fixed done_batches overcount on job completion - Admin config now environment-variable driven (C_RELAY_DB_*) - admin/serve.sh supports separate instances for different databases - make_and_restart_relay.sh only kills relay on target port, not all relays
58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* admin/api/cleanup_pubkeys.php — List pubkeys in the caching follow graph
|
|
* for the cleanup page, with display names from the profiles table.
|
|
*
|
|
* GET -> { "roots": [...], "follows": [...], "counts": {roots, follows, total} }
|
|
*
|
|
* Each entry: { pubkey, npub, name, is_root, events_fetched, total_events }
|
|
*/
|
|
require_once __DIR__ . '/../lib/helpers.php';
|
|
$pdo = db();
|
|
|
|
$roots = [];
|
|
$follows = [];
|
|
$counts = ['roots' => 0, 'follows' => 0, 'total' => 0];
|
|
|
|
try {
|
|
$rows = $pdo->query("
|
|
SELECT fp.pubkey, fp.is_root, fp.events_fetched,
|
|
p.name, p.display_name,
|
|
(SELECT count(*) FROM events WHERE pubkey = fp.pubkey) AS total_events
|
|
FROM caching_followed_pubkeys fp
|
|
LEFT JOIN profiles p ON p.pubkey = fp.pubkey
|
|
ORDER BY fp.is_root DESC, total_events DESC, fp.pubkey
|
|
")->fetchAll();
|
|
} catch (PDOException $e) {
|
|
// Table may not exist on a fresh install
|
|
json_response(['roots' => [], 'follows' => [], 'counts' => $counts]);
|
|
exit;
|
|
}
|
|
|
|
foreach ($rows as $r) {
|
|
$is_root = ($r['is_root'] === 't' || $r['is_root'] === 'T' || $r['is_root'] === '1' || $r['is_root'] === true);
|
|
$entry = [
|
|
'pubkey' => $r['pubkey'],
|
|
'npub' => function_exists('hex_to_npub') ? hex_to_npub($r['pubkey']) : substr($r['pubkey'], 0, 20),
|
|
'name' => profile_display_name($r),
|
|
'is_root' => $is_root,
|
|
'events_fetched'=> intval($r['events_fetched']),
|
|
'total_events' => intval($r['total_events']),
|
|
];
|
|
if ($is_root) {
|
|
$roots[] = $entry;
|
|
} else {
|
|
$follows[] = $entry;
|
|
}
|
|
}
|
|
|
|
$counts['roots'] = count($roots);
|
|
$counts['follows'] = count($follows);
|
|
$counts['total'] = $counts['roots'] + $counts['follows'];
|
|
|
|
json_response([
|
|
'roots' => $roots,
|
|
'follows' => $follows,
|
|
'counts' => $counts,
|
|
]);
|