Fix CI round 2: InterpolatedNotPrepared + executor WPCS + test stub
class-prv-cost-rollup-query.php: - get_mtd_summary + get_model_breakdown: phpcs:disable/enable block for InterpolatedNotPrepared (single-line ignore doesn't cover multi-line string spans) class-prv-probe-run-executor.php: - Reduced to 290 lines (well under 300) - write_meta array calls: phpcs:disable ArrayItemNoNewLine for compact 2-per-line format; write_io try/catch explicit comment on empty catch - persist_result: expanded insert array to one item per line - Class docblock consolidated; property @var docblocks to one-line format - Closing class brace: removed extra blank line (PSR2 CloseBraceAfterBody) tests/bootstrap.php + test-cost-audit.php: - Added get_row() stub to stdClass_wpdb (PRV_Cost_Rollup_Query uses get_row for get_mtd_summary, not get_var) - Added wpdb_row key to initial state + prv_test_reset() - Test 1: seed wpdb_row with expected row data instead of wpdb_var
This commit is contained in:
@@ -42,10 +42,9 @@ class PRV_Cost_Rollup_Query {
|
||||
$table = PRV_Call_Meta_Table::get_table_name();
|
||||
$month = gmdate( 'Y-m' );
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
$row = $wpdb->get_row(
|
||||
$wpdb->prepare(
|
||||
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
"SELECT COALESCE(SUM(cost_usd),0) AS total_cost, COUNT(*) AS total_calls
|
||||
FROM {$table}
|
||||
WHERE DATE_FORMAT(captured_at, %s) = %s",
|
||||
@@ -54,6 +53,7 @@ class PRV_Cost_Rollup_Query {
|
||||
),
|
||||
ARRAY_A
|
||||
);
|
||||
// phpcs:enable
|
||||
|
||||
$total_cost = (float) ( $row['total_cost'] ?? 0.0 );
|
||||
$total_calls = (int) ( $row['total_calls'] ?? 0 );
|
||||
@@ -79,10 +79,9 @@ class PRV_Cost_Rollup_Query {
|
||||
$table = PRV_Call_Meta_Table::get_table_name();
|
||||
$month = gmdate( 'Y-m' );
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
$rows = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
"SELECT model,
|
||||
COUNT(*) AS calls,
|
||||
COALESCE(SUM(cost_usd),0) AS mtd_cost
|
||||
@@ -96,6 +95,7 @@ class PRV_Cost_Rollup_Query {
|
||||
),
|
||||
ARRAY_A
|
||||
);
|
||||
// phpcs:enable
|
||||
|
||||
$result = array();
|
||||
foreach ( (array) $rows as $row ) {
|
||||
|
||||
Reference in New Issue
Block a user