Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1860

Přidáno uživatelem Ondřej Fibich před více než 11 roky(ů)

Optimalizace:
- #415: Optimalizace fronty e-mailu

Zobrazit rozdíly:

freenetis/branches/1.1/application/helpers/callback.php
*/
public static function email_subject_field ($item, $name)
{
$body = preg_replace('<(br|BR)( ?\/)?>', '\n', $item->body);
$body = strip_tags($body);
echo "<span class='help' title='".$body."'>".$item->subject."</span>";
echo "<span";
if (isset($item->body))
{
$body = strip_tags(nl2br($item->body));
$sbody = strip_tags($body);
echo " class='help' title='$sbody'";
}
echo ">$item->subject</span>";
}
/**
freenetis/branches/1.1/application/models/email_queue.php
/**
* Unsuccessfully sent e-mail, almost same as new
*/
const STATE_FAIL = 2;
const STATE_FAIL = 2;
/**
* Returns current email queue, by default 10 e-mails to send
......
// filter
$where = "";
if ($filter_sql != '')
$where = " AND $filter_sql";
$where = "WHERE $filter_sql";
return $this->db->query("
SELECT * FROM
(
SELECT eq.*,
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
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 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 eq.state = ? $where
$where
GROUP BY eq.id
ORDER BY ".$this->db->escape_column($order_by)." $order_by_direction
LIMIT " . intval($limit_from) . "," . intval($limit_results) . "
......
*/
public function count_all_sent_emails($filter_sql='')
{
if (empty($filter_sql))
{
return $this->db->query("
SELECT COUNT(*) AS total
FROM email_queues eq
WHERE eq.state = ?
", self::STATE_OK)->current()->total;
}
// filter
$where = "";
if ($filter_sql != '')
$where = " AND $filter_sql";
$where = "WHERE $filter_sql";
return $this->db->query("
SELECT COUNT(*) AS total FROM
(
SELECT eq.id FROM
(
SELECT eq.*,
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
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 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 eq.state = ? $where
WHERE $filter_sql
GROUP BY eq.id
) eq
", Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL, self::STATE_OK)
->current()->total;
", array
(
Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL,
self::STATE_OK
))->current()->total;
}
/**
......
// filter
$where = "";
if ($filter_sql != '')
$where = " AND $filter_sql";
$where = "WHERE $filter_sql";
return $this->db->query("
SELECT * FROM
(
SELECT eq.*,
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
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 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 eq.state <> ? $where
$where
GROUP BY eq.id
ORDER BY ".$this->db->escape_column($order_by)." $order_by_direction
LIMIT " . intval($limit_from) . "," . intval($limit_results) . "
......
*/
public function count_all_unsent_emails($filter_sql='')
{
// filter
$where = "";
if ($filter_sql != '')
$where = " AND $filter_sql";
if (empty($filter_sql))
{
return $this->db->query("
SELECT COUNT(*) AS total
FROM email_queues eq
WHERE eq.state <> ?
", self::STATE_OK)->current()->total;
}
return $this->db->query("
SELECT COUNT(*) AS total FROM
(
SELECT eq.id FROM
(
SELECT eq.*,
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
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 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 eq.state <> ? $where
WHERE $filter_sql
GROUP BY eq.id
) eq
", Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL, self::STATE_OK)
->current()->total;
", array
(
Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL,
self::STATE_OK
))->current()->total;
}
/**
freenetis/branches/1.1/application/models/sms_message.php
u.id AS sender_id,
CONCAT(u.surname,' ',u.name) AS sender_name,
IFNULL(e.value, m.type) AS sender_type
FROM contacts c
JOIN contacts_countries cc ON cc.contact_id = c.id
JOIN countries cu ON cc.country_id = cu.id
JOIN users_contacts uc ON uc.contact_id = c.id
JOIN users u ON uc.user_id = u.id
JOIN members m ON u.member_id = m.id
LEFT JOIN enum_types e ON m.type = e.id AND read_only = 0
FROM contacts c
JOIN contacts_countries cc ON cc.contact_id = c.id
JOIN countries cu ON cc.country_id = cu.id
JOIN users_contacts uc ON uc.contact_id = c.id
JOIN users u ON uc.user_id = u.id
JOIN members m ON u.member_id = m.id
LEFT JOIN enum_types e ON m.type = e.id AND read_only = 0
WHERE c.type = ?
) s ON sms.sender LIKE s.value
LEFT JOIN
......
u.id AS receiver_id,
CONCAT(u.surname,' ',u.name) AS receiver_name,
IFNULL(e.value, m.type) AS receiver_type
FROM contacts c
JOIN contacts_countries cc ON cc.contact_id = c.id
JOIN countries cu ON cc.country_id = cu.id
JOIN users_contacts uc ON uc.contact_id = c.id
JOIN users u ON uc.user_id = u.id
JOIN members m ON u.member_id = m.id
LEFT JOIN enum_types e ON m.type = e.id AND read_only = 0
FROM contacts c
JOIN contacts_countries cc ON cc.contact_id = c.id
JOIN countries cu ON cc.country_id = cu.id
JOIN users_contacts uc ON uc.contact_id = c.id
JOIN users u ON uc.user_id = u.id
JOIN members m ON u.member_id = m.id
LEFT JOIN enum_types e ON m.type = e.id AND read_only = 0
WHERE c.type = ?
) r ON sms.receiver LIKE r.value
$where
freenetis/branches/1.1/application/controllers/email_queues.php
$filter_form->add('subject');
$filter_form->add('body');
$filter_form->add('access_time')
->type('date')
->label(__('Time'));
......
$actions = $grid->grouped_action_field();
$actions->add_action()
->icon_action('show')
->url('email/show');
$actions->add_action()
->icon_action('mail_send')
->label('Send again')
->url('email_queues/send');
......
$filter_form->add('subject');
$filter_form->add('body');
$filter_form->add('access_time')
->type('date')
->label(__('Time'));

Také k dispozici: Unified diff