Alerts overlay: show messages approved after later donations (recent mode with client-side dedupe)
Test and Release / test (push) Successful in 1m10s
Test and Release / release (push) Successful in 5s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-15 12:26:03 -08:00
1 parent 875ca42054
commit f7ff1dc717
7 files changed
+170 -24

No files matched your search

+11 -1
View File
@@ -4,7 +4,7 @@ declare( strict_types=1 );
namespace StreamGoals\Overlay;
/** $wpdb adapter reading sg_goals, sg_donations, sg_state, sg_rules directly. */
final class WpdbDataSource implements OverlayDataSource {
final class WpdbDataSource implements OverlayDataSource, RecentDonationsSource {
private function t( string $name ): string {
global $wpdb;
@@ -102,4 +102,14 @@ final class WpdbDataSource implements OverlayDataSource {
}
return (array) $rows;
}
public function recentDonations( int $limit ): array {
global $wpdb;
$rows = $wpdb->get_results( $wpdb->prepare(
"SELECT id, base_minor, currency, donor_name, is_anonymous, message, status, moderation FROM {$this->t('donations')}
WHERE status = 'completed' AND moderation = 'approved' ORDER BY id DESC LIMIT %d",
max( 1, $limit )
), ARRAY_A );
return array_reverse( (array) $rows );
}
}