This commit is contained in:
Mario Fetka
2014-04-16 11:25:38 +02:00
parent d21230a2ed
commit 401edac1a7
2 changed files with 24 additions and 25 deletions

View File

@@ -132,35 +132,35 @@ class DBEngine {
MAX(stattable.pending) AS pending
FROM (
SELECT CAST(time_iso AS DATE) AS date,
COUNT(content) AS spam,
COUNT(msgs.content) AS spam,
0 AS banned,
0 AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
WHERE content='S' AND NOT (msgs.quar_type = '')
WHERE msgs.content='S' AND NOT (msgs.quar_type = '')
AND msgrcpt.rs IN ('','v')
GROUP BY CAST(time_iso AS DATE)
UNION
SELECT CAST(time_iso AS DATE) AS date,
0 AS spam,
COUNT(content) AS banned,
COUNT(msgs.content) AS banned,
0 AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
WHERE content='B' AND NOT (msgs.quar_type = '')
WHERE msgs.content='B' AND NOT (msgs.quar_type = '')
AND msgrcpt.rs IN ('','v')
GROUP BY CAST(time_iso AS DATE)
UNION
SELECT CAST(time_iso AS DATE) AS date,
0 AS spam,
0 AS banned,
COUNT(content) AS viruses,
COUNT(msgs.content) AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
WHERE content='V' AND NOT (msgs.quar_type = '')
WHERE msgs.content='V' AND NOT (msgs.quar_type = '')
AND msgrcpt.rs IN ('','v')
GROUP BY CAST(time_iso AS DATE)
UNION
@@ -168,10 +168,10 @@ class DBEngine {
0 AS spam,
0 AS banned,
0 AS viruses,
COUNT(content) AS badheaders,
COUNT(msgs.content) AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
WHERE content='H' AND NOT (msgs.quar_type = '')
WHERE msgs.content='H' AND NOT (msgs.quar_type = '')
AND msgrcpt.rs IN ('','v')
GROUP BY CAST(time_iso AS DATE)
UNION
@@ -180,7 +180,7 @@ class DBEngine {
0 AS banned,
0 AS viruses,
0 AS badheaders,
COUNT(content) AS pending
COUNT(msgs.content) AS pending
FROM msgs JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
WHERE msgrcpt.rs='p' AND NOT (msgs.quar_type = '')
GROUP BY CAST(time_iso AS DATE)
@@ -188,7 +188,6 @@ class DBEngine {
GROUP BY date
ORDER BY date";
// Prepare query
$q = $this->db->prepare($query);
// Execute query
@@ -253,38 +252,38 @@ class DBEngine {
MAX(stattable.pending) AS pending
FROM (
SELECT CAST(time_iso AS DATE) AS date,
COUNT(content) AS spam,
COUNT(msgs.content) AS spam,
0 AS banned,
0 AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
$join_type maddr AS recip ON msgrcpt.rid=recip.id
WHERE content='S' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
WHERE msgs.content='S' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
AND $recipEmailClause
GROUP BY CAST(time_iso AS DATE)
UNION
SELECT CAST(time_iso AS DATE) AS date,
0 AS spam,
COUNT(content) AS banned,
COUNT(msgs.content) AS banned,
0 AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
$join_type maddr AS recip ON msgrcpt.rid=recip.id
WHERE content='B' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
WHERE msgs.content='B' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
AND $recipEmailClause
GROUP BY CAST(time_iso AS DATE)
UNION
SELECT CAST(time_iso AS DATE) AS date,
0 AS spam,
0 AS banned,
COUNT(content) AS viruses,
COUNT(msgs.content) AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
$join_type maddr AS recip ON msgrcpt.rid=recip.id
WHERE content='V' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
WHERE msgs.content='V' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
AND $recipEmailClause
GROUP BY CAST(time_iso AS DATE)
UNION
@@ -292,11 +291,11 @@ class DBEngine {
0 AS spam,
0 AS banned,
0 AS viruses,
COUNT(content) AS badheaders,
COUNT(msgs.content) AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
$join_type maddr AS recip ON msgrcpt.rid=recip.id
WHERE content='H' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
WHERE msgs.content='H' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
AND $recipEmailClause
GROUP BY CAST(time_iso AS DATE)
UNION
@@ -305,7 +304,7 @@ class DBEngine {
0 AS banned,
0 AS viruses,
0 AS badheaders,
COUNT(content) AS pending
COUNT(msgs.content) AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
$join_type maddr AS recip ON msgrcpt.rid=recip.id
WHERE msgrcpt.rs='p' AND NOT (msgs.quar_type = '')