Skip to content

Commit

Permalink
Merge pull request #107 from sjefmoling/fix_prefixed_tables
Browse files Browse the repository at this point in the history
add prefix to tables in raw select
  • Loading branch information
JonoB authored Feb 26, 2021
2 parents fa1ae8b + ce0a3e6 commit 4d30043
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Repositories/Campaigns/BaseCampaignTenantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public function getCounts(Collection $campaignIds, int $workspaceId): array
->where('sendportal_messages.workspace_id', $workspaceId);
})
->select('sendportal_campaigns.id as campaign_id')
->selectRaw('count(sendportal_messages.id) as total')
->selectRaw('count(case when sendportal_messages.opened_at IS NOT NULL then 1 end) as opened')
->selectRaw('count(case when sendportal_messages.clicked_at IS NOT NULL then 1 end) as clicked')
->selectRaw('count(case when sendportal_messages.sent_at IS NOT NULL then 1 end) as sent')
->selectRaw('count(case when sendportal_messages.bounced_at IS NOT NULL then 1 end) as bounced')
->selectRaw('count(case when sendportal_messages.sent_at IS NULL then 1 end) as pending')
->selectRaw(sprintf('count(%ssendportal_messages.id) as total', DB::getTablePrefix()))
->selectRaw(sprintf('count(case when %ssendportal_messages.opened_at IS NOT NULL then 1 end) as opened', DB::getTablePrefix()))
->selectRaw(sprintf('count(case when %ssendportal_messages.clicked_at IS NOT NULL then 1 end) as clicked', DB::getTablePrefix()))
->selectRaw(sprintf('count(case when %ssendportal_messages.sent_at IS NOT NULL then 1 end) as sent', DB::getTablePrefix()))
->selectRaw(sprintf('count(case when %ssendportal_messages.bounced_at IS NOT NULL then 1 end) as bounced', DB::getTablePrefix()))
->selectRaw(sprintf('count(case when %ssendportal_messages.sent_at IS NULL then 1 end) as pending', DB::getTablePrefix()))
->groupBy('sendportal_campaigns.id')
->orderBy('sendportal_campaigns.id')
->get();
Expand Down

0 comments on commit 4d30043

Please # to comment.