Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 4b851957

Přidáno uživatelem Ondřej Fibich před více než 7 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.

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 = ?
GROUP BY eq.id
$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 = ?
) eq
$where
", array
(
Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL,
self::STATE_OK
))->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 <> ?
GROUP BY eq.id
$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
) eq
$where
", array
(
Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL,
self::STATE_OK
))->count();
self::STATE_OK,
Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL
))->current()->count;
}
/**

Také k dispozici: Unified diff