- Updates statistics SQL query

- Fixes tests + expands coverage
- Removes leftover console command
This commit is contained in:
Vlad
2016-04-27 14:10:21 -04:00
committed by Tautvidas Sipavičius
parent 18f35b5e91
commit ae358ce13e
4 changed files with 33 additions and 15 deletions

View File

@ -68,7 +68,7 @@ class Newsletter extends Model {
function getQueue() {
return SendingQueue::where('newsletter_id', $this->id)
->whereNotEqual('status', 'scheduled')
->whereRaw(('`status` IS NULL OR `status` != "scheduled"'))
->orderByDesc('updated_at')
->findOne();
}
@ -103,17 +103,17 @@ class Newsletter extends Model {
'count(DISTINCT(opens.id)) as opened, ' .
'count(DISTINCT(unsubscribes.id)) as unsubscribed '
)
->join(
->leftOuterJoin(
MP_STATISTICS_CLICKS_TABLE,
'queues.id = clicks.queue_id',
'clicks'
)
->join(
->leftOuterJoin(
MP_STATISTICS_OPENS_TABLE,
'queues.id = opens.queue_id',
'opens'
)
->join(
->leftOuterJoin(
MP_STATISTICS_UNSUBSCRIBES_TABLE,
'queues.id = unsubscribes.queue_id',
'unsubscribes'
@ -122,7 +122,6 @@ class Newsletter extends Model {
->findOne();
}
static function search($orm, $search = '') {
return $orm->where_like('subject', '%' . $search . '%');
}