Alerts overlay: show messages approved after later donations (recent mode with client-side dedupe)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
875ca42054
commit
f7ff1dc717
7 files changed
+170
-24
No files matched your search
@@ -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 );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user