mirror of
https://github.com/Mibew/design.git
synced 2025-01-22 18:10:33 +03:00
Calculate thread statistics that older one day
This commit is contained in:
parent
1a4d8e809d
commit
1cde50242d
@ -59,13 +59,7 @@ function calculate_thread_statistics() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$start = empty($result['start']) ? 0 : $result['start'];
|
$start = empty($result['start']) ? 0 : $result['start'];
|
||||||
|
$today = floor(time() / (24*60*60)) * 24*60*60;
|
||||||
// Reset statistics for the last day, because cron can be ran many
|
|
||||||
// times in a day.
|
|
||||||
$result = $db->query(
|
|
||||||
"DELETE FROM {chatthreadstatistics} WHERE date = :start",
|
|
||||||
array(':start' => $start)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Calculate statistics
|
// Calculate statistics
|
||||||
$db->query(
|
$db->query(
|
||||||
@ -95,13 +89,16 @@ function calculate_thread_statistics() {
|
|||||||
"WHERE m.threadid = t.threadid " .
|
"WHERE m.threadid = t.threadid " .
|
||||||
"AND tmp.threadid = t.threadid " .
|
"AND tmp.threadid = t.threadid " .
|
||||||
"AND t.dtmchatstarted <> 0 " .
|
"AND t.dtmchatstarted <> 0 " .
|
||||||
"AND m.dtmcreated > :start " .
|
"AND (m.dtmcreated - :start) > 24*60*60 " .
|
||||||
|
// Calculate statistics only for threads that older than one day
|
||||||
|
"AND (:today - m.dtmcreated) > 24*60*60 " .
|
||||||
"GROUP BY date " .
|
"GROUP BY date " .
|
||||||
"ORDER BY date",
|
"ORDER BY date",
|
||||||
array(
|
array(
|
||||||
':kind_agent' => Thread::KIND_AGENT,
|
':kind_agent' => Thread::KIND_AGENT,
|
||||||
':kind_user' => Thread::KIND_USER,
|
':kind_user' => Thread::KIND_USER,
|
||||||
':start' => $start
|
':start' => $start,
|
||||||
|
':today' => $today
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user