Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1d9077c2

Přidáno uživatelem Ondřej Fibich před téměř 8 roky(ů)

Refs #1053: Default sort in emails set to ID which is indexed (previously by access_time), some small improvements in related queries but filters are still very slow.

Conflicts:
application/models/email_queue.php

Zobrazit rozdíly:

application/controllers/email_queues.php
* @param integer $page
*/
public function show_all_unsent(
$limit_results = 50, $order_by = 'access_time',
$limit_results = 50, $order_by = 'id',
$order_by_direction = 'DESC', $page_word = null, $page = 1)
{
// access check
......
// order by check
if (!in_array(strtolower($order_by), $allowed_order_type))
$order_by = 'access_time';
$order_by = 'id';
// order by direction check
if (strtolower($order_by_direction) != 'asc')
......
* @param integer $page
*/
public function show_all_sent(
$limit_results = 50, $order_by = 'access_time',
$limit_results = 50, $order_by = 'id',
$order_by_direction = 'DESC', $page_word = null, $page = 1)
{
// access check
......
// order by check
if (!in_array(strtolower($order_by), $allowed_order_type))
$order_by = 'access_time';
$order_by = 'id';
// order by direction check
if (strtolower($order_by_direction) != 'asc')
application/models/email_queue.php
}
// filter
$having = "";
$where = "";
if ($filter_sql != '')
$having = "HAVING $filter_sql";
$where = "WHERE $filter_sql";
return $this->db->query("
SELECT eq.id, eq.from, eq.to, eq.subject, eq.state, eq.access_time,
fuc.user_id AS from_user_id,
CONCAT(fu.name,' ',fu.surname) AS from_user_name,
tuc.user_id AS to_user_id,
CONCAT(tu.name,' ',tu.surname) AS to_user_name
FROM email_queues eq
LEFT JOIN contacts fc ON eq.from = fc.value AND fc.type = ?
LEFT JOIN users_contacts fuc ON fc.id = fuc.contact_id
LEFT JOIN users fu ON fuc.user_id = fu.id
LEFT JOIN contacts tc ON eq.to = tc.value AND tc.type = ?
LEFT JOIN users_contacts tuc ON tc.id = tuc.contact_id
LEFT JOIN users tu ON tuc.user_id = tu.id
WHERE eq.state = ? OR eq.state = ?
$having
SELECT COUNT(eq.id) as count
FROM
(
SELECT eq.id, eq.from, eq.to, eq.subject, eq.state, eq.access_time,
fuc.user_id AS from_user_id,
CONCAT(fu.name,' ',fu.surname) AS from_user_name,
tuc.user_id AS to_user_id,
CONCAT(tu.name,' ',tu.surname) AS to_user_name
FROM email_queues eq
LEFT JOIN contacts fc ON eq.from = fc.value AND fc.type = ?
LEFT JOIN users_contacts fuc ON fc.id = fuc.contact_id
LEFT JOIN users fu ON fuc.user_id = fu.id
LEFT JOIN contacts tc ON eq.to = tc.value AND tc.type = ?
LEFT JOIN users_contacts tuc ON tc.id = tuc.contact_id
LEFT JOIN users tu ON tuc.user_id = tu.id
WHERE eq.state = ? OR eq.state = ?
) eq
$where
", array
(
Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL,
self::STATE_OK, self::STATE_READ
))->count();
))->current()->count;
}
/**
......
}
// filter
$having = "";
$where = "";
if ($filter_sql != '')
$having = 'HAVING '.$filter_sql;
$where = 'WHERE '.$filter_sql;
return $this->db->query("
SELECT eq.id, eq.from, eq.to, eq.subject, eq.state, eq.access_time,
fuc.user_id,
CONCAT(fu.name,' ',fu.surname) AS from_user_name,
tuc.user_id,
CONCAT(tu.name,' ',tu.surname) AS to_user_name
FROM email_queues eq
LEFT JOIN contacts fc ON eq.from = fc.value AND fc.type = ?
LEFT JOIN users_contacts fuc ON fc.id = fuc.contact_id
LEFT JOIN users fu ON fuc.user_id = fu.id
LEFT JOIN contacts tc ON eq.to = tc.value AND tc.type = ?
LEFT JOIN users_contacts tuc ON tc.id = tuc.contact_id
LEFT JOIN users tu ON tuc.user_id = tu.id
WHERE eq.state <> ? AND eq.state <> ?
$having
SELECT COUNT(eq.id) as count
FROM
(
SELECT eq.id, eq.from, eq.to, eq.subject, eq.state, eq.access_time,
fuc.user_id AS from_user_id,
CONCAT(fu.name,' ',fu.surname) AS from_user_name,
tuc.user_id AS to_user_id,
CONCAT(tu.name,' ',tu.surname) AS to_user_name
FROM email_queues eq
LEFT JOIN contacts fc ON eq.from = fc.value AND fc.type = ?
LEFT JOIN users_contacts fuc ON fc.id = fuc.contact_id
LEFT JOIN users fu ON fuc.user_id = fu.id
LEFT JOIN contacts tc ON eq.to = tc.value AND tc.type = ?
LEFT JOIN users_contacts tuc ON tc.id = tuc.contact_id
LEFT JOIN users tu ON tuc.user_id = tu.id
WHERE eq.state <> ? AND eq.state <> ?
) eq
$where
", array
(
Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL,
self::STATE_OK, self::STATE_READ
))->count();
))->current()->count;
}
/**

Také k dispozici: Unified diff