db->get_var(
"SELECT COUNT(*) FROM `" . WPF()->tables->topics . "`"
);
set_transient( $_ttc_cache_key, $total_topics_count, 10 * MINUTE_IN_SECONDS );
}
$total_topics_count = (int) $total_topics_count;
// Get available credits from status
$subscription = isset( $status['subscription'] ) && is_array( $status['subscription'] ) ? $status['subscription'] : [];
$credits_remaining = isset( $subscription['credits_remaining'] ) ? (int) $subscription['credits_remaining'] : 0;
// Calculate remaining topics to index (not already indexed)
// Note: $total_topics = unique topics with embeddings, $total_indexed = total embeddings (can be > topics due to chunking)
$remaining_to_index = max( 0, $total_topics_count - $total_topics );
// Calculate how many topics can be indexed with available credits
# $credits_needed = $total_topics_count; // Max credits if indexing from scratch
$can_index_count = min( $remaining_to_index, $credits_remaining );
$has_enough_credits = $credits_remaining >= $remaining_to_index;
$all_indexed = $remaining_to_index === 0;
?>
' . number_format( $pending_topics_count ) . ''
);
?>
0 && $credits_remaining > 0;
?>