Question_Log
Stores asked questions for the Content gaps report.
Rows hold the question, whether it was answered, the source article IDs, whether the
answer was cached, and the time. No IP addresses or user identifiers are stored. The
source column defaults to ai so a future KB search tracker can share the table.
Namespace: WebberZone\Better_Search\Pro\AI
Since: 4.5.0
Source: includes/pro/ai/class-question-log.php line 25
Methods
__construct()
Constructor.
Line: 51
public function __construct( );
is_enabled() static
Whether questions are recorded for the Content gaps report.
Since: 4.5.0
Line: 65
static public function is_enabled( ): bool;
Returns: bool — True if recording is on.
table() static
Table name.
Since: 4.5.0
Line: 76
static public function table( ): string;
Returns: string — Table name with prefix.
maybe_install()
Create or update the table when the schema version changes.
Since: 4.5.0
Line: 87
public function maybe_install( ): void;
Returns: void
install() static
Create or update the table.
Since: 4.5.0
Line: 98
static public function install( ): void;
Returns: void
record()
Record a question.
Since: 4.5.0
Line: 135
public function record( $question, $result, $cached ): void;
| Type | Name | Description |
|---|---|---|
string |
$question |
Question. |
array |
$result |
Result with answered and sources. |
bool |
$cached |
Whether the answer came from the cache. |
Returns: void
schedule_cleanup()
Schedule the daily cleanup.
Since: 4.5.0
Line: 175
public function schedule_cleanup( ): void;
Returns: void
cleanup() static
Delete rows older than the retention period.
Since: 4.5.0
Line: 188
static public function cleanup( ): int;
Returns: int — Rows deleted.
clear() static
Delete every recorded question.
Since: 4.5.0
Line: 209
static public function clear( ): int;
Returns: int — Rows deleted.
count() static
Number of recorded questions.
Since: 4.5.0
Line: 225
static public function count( ): int;
Returns: int — Count.
get_totals() static
Question totals for a date range.
Since: 4.5.0
Line: 243
static public function get_totals( string $from, string $to ): array;
| Type | Name | Description |
|---|---|---|
string |
$from |
Start, GMT Y-m-d H:i:s. |
string |
$to |
End, GMT Y-m-d H:i:s. |
Returns: array — Array with total, answered, unanswered and cached.
get_unanswered_groups() static
Unanswered questions grouped by normalised text, most asked first.
Since: 4.5.0
Line: 273
static public function get_unanswered_groups( string $from, string $to, int $per_page = ..., int $page = ... ): array;
| Type | Name | Description |
|---|---|---|
string |
$from |
Start, GMT Y-m-d H:i:s. |
string |
$to |
End, GMT Y-m-d H:i:s. |
int |
$per_page |
Rows per page. 0 for all. |
int |
$page |
Page number, from 1. |
Returns: array — Rows with question, count and last_asked (GMT).
count_unanswered_groups() static
Number of distinct unanswered questions in a date range.
Since: 4.5.0
Line: 303
static public function count_unanswered_groups( string $from, string $to ): int;
| Type | Name | Description |
|---|---|---|
string |
$from |
Start, GMT Y-m-d H:i:s. |
string |
$to |
End, GMT Y-m-d H:i:s. |
Returns: int — Count.
uninstall() static
Remove all AI answers data: the question log table, options, cached answers, rate-limit counters and the cleanup event. Called from uninstaller.php.
Question text is always deleted, whatever the uninstall data setting, because the retention period cannot be enforced once the plugin is gone.
Since: 4.5.0
Line: 321
static public function uninstall( ): void;
Returns: void