mirror of
https://github.com/Mibew/java.git
synced 2025-01-22 17:40:35 +03:00
Add statistics aggregation interval
This commit is contained in:
parent
dae493b1a8
commit
1a0b315365
@ -98,6 +98,8 @@ Class Settings {
|
|||||||
'updatefrequency_operator' => 2,
|
'updatefrequency_operator' => 2,
|
||||||
'updatefrequency_chat' => 2,
|
'updatefrequency_chat' => 2,
|
||||||
|
|
||||||
|
'statistics_aggregation_interval' => 24*60*60,
|
||||||
|
|
||||||
'updatefrequency_tracking' => 10,
|
'updatefrequency_tracking' => 10,
|
||||||
'visitors_limit' => 20, /* Number of visitors to look over */
|
'visitors_limit' => 20, /* Number of visitors to look over */
|
||||||
'invitation_lifetime' => 60, /* Lifetime for invitation to chat */
|
'invitation_lifetime' => 60, /* Lifetime for invitation to chat */
|
||||||
|
@ -47,6 +47,8 @@ function calculate_thread_statistics() {
|
|||||||
$db = Database::getInstance();
|
$db = Database::getInstance();
|
||||||
$db_throw_exceptions = $db->throwExeptions(true);
|
$db_throw_exceptions = $db->throwExeptions(true);
|
||||||
|
|
||||||
|
$interval = Settings::get('statistics_aggregation_interval');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Start transaction
|
// Start transaction
|
||||||
$db->query('START TRANSACTION');
|
$db->query('START TRANSACTION');
|
||||||
@ -59,12 +61,12 @@ 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;
|
$today = floor(time() / $interval) * $interval;
|
||||||
|
|
||||||
// Calculate statistics
|
// Calculate statistics
|
||||||
// Get base threads info
|
// Get base threads info
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT (FLOOR(t.dtmcreated / (24*60*60)) * 24*60*60) AS date, " .
|
"SELECT (FLOOR(t.dtmcreated / :interval) * :interval) AS date, " .
|
||||||
"COUNT(t.threadid) AS threads, " .
|
"COUNT(t.threadid) AS threads, " .
|
||||||
"SUM(tmp.operator_msgs) AS operator_msgs, " .
|
"SUM(tmp.operator_msgs) AS operator_msgs, " .
|
||||||
"SUM(tmp.user_msgs) AS user_msgs, " .
|
"SUM(tmp.user_msgs) AS user_msgs, " .
|
||||||
@ -88,9 +90,10 @@ function calculate_thread_statistics() {
|
|||||||
"OR m.ikind = :kind_agent " .
|
"OR m.ikind = :kind_agent " .
|
||||||
"GROUP BY m.threadid) tmp " .
|
"GROUP BY m.threadid) tmp " .
|
||||||
"WHERE t.threadid = tmp.threadid " .
|
"WHERE t.threadid = tmp.threadid " .
|
||||||
"AND (t.dtmcreated - :start) > 24*60*60 " .
|
"AND (t.dtmcreated - :start) > :interval " .
|
||||||
// Calculate statistics only for threads that older than one day
|
// Calculate statistics only for threads that older than
|
||||||
"AND (:today - t.dtmcreated) > 24*60*60 " .
|
// statistics_aggregation_interval
|
||||||
|
"AND (:today - t.dtmcreated) > :interval " .
|
||||||
// Ignore threads when operator does not start chat
|
// Ignore threads when operator does not start chat
|
||||||
"AND t.dtmchatstarted <> 0 " .
|
"AND t.dtmchatstarted <> 0 " .
|
||||||
// Ignore not accepted invitations
|
// Ignore not accepted invitations
|
||||||
@ -100,6 +103,7 @@ function calculate_thread_statistics() {
|
|||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today,
|
':today' => $today,
|
||||||
|
':interval' => $interval,
|
||||||
':not_invited' => Thread::INVITATION_NOT_INVITED,
|
':not_invited' => Thread::INVITATION_NOT_INVITED,
|
||||||
':invitation_accepted' => Thread::INVITATION_ACCEPTED,
|
':invitation_accepted' => Thread::INVITATION_ACCEPTED,
|
||||||
':kind_agent' => Thread::KIND_AGENT,
|
':kind_agent' => Thread::KIND_AGENT,
|
||||||
@ -117,12 +121,13 @@ function calculate_thread_statistics() {
|
|||||||
|
|
||||||
// Get info about missed threads
|
// Get info about missed threads
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT (FLOOR(dtmcreated / (24*60*60)) * 24*60*60) AS date, " .
|
"SELECT (FLOOR(dtmcreated / :interval) * :interval) AS date, " .
|
||||||
"COUNT(*) as missed_threads " .
|
"COUNT(*) as missed_threads " .
|
||||||
"FROM {chatthread} " .
|
"FROM {chatthread} " .
|
||||||
"WHERE (dtmcreated - :start) > 24*60*60 " .
|
"WHERE (dtmcreated - :start) > :interval " .
|
||||||
// Calculate statistics only for threads that older than one day
|
// Calculate statistics only for threads that older than
|
||||||
"AND (:today - dtmcreated) > 24*60*60 " .
|
// statistics_aggregation_interval
|
||||||
|
"AND (:today - dtmcreated) > :interval " .
|
||||||
// Ignore threads when operator does not start chat
|
// Ignore threads when operator does not start chat
|
||||||
"AND dtmchatstarted = 0 " .
|
"AND dtmchatstarted = 0 " .
|
||||||
// Ignore not accepted invitations
|
// Ignore not accepted invitations
|
||||||
@ -131,6 +136,7 @@ function calculate_thread_statistics() {
|
|||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today,
|
':today' => $today,
|
||||||
|
':interval' => $interval,
|
||||||
':not_invited' => Thread::INVITATION_NOT_INVITED
|
':not_invited' => Thread::INVITATION_NOT_INVITED
|
||||||
),
|
),
|
||||||
array('return_rows' => Database::RETURN_ALL_ROWS)
|
array('return_rows' => Database::RETURN_ALL_ROWS)
|
||||||
@ -145,12 +151,13 @@ function calculate_thread_statistics() {
|
|||||||
|
|
||||||
// Get info about average waiting time.
|
// Get info about average waiting time.
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT (FLOOR(dtmcreated / (24*60*60)) * 24*60*60) AS date, " .
|
"SELECT (FLOOR(dtmcreated / :interval) * :interval) AS date, " .
|
||||||
"ROUND(AVG(dtmchatstarted-dtmcreated),1) AS avg_waiting_time " .
|
"ROUND(AVG(dtmchatstarted-dtmcreated),1) AS avg_waiting_time " .
|
||||||
"FROM {chatthread} " .
|
"FROM {chatthread} " .
|
||||||
"WHERE (dtmcreated - :start) > 24*60*60 " .
|
"WHERE (dtmcreated - :start) > :interval " .
|
||||||
// Calculate statistics only for threads that older than one day
|
// Calculate statistics only for threads that older than
|
||||||
"AND (:today - dtmcreated) > 24*60*60 " .
|
// statistics_aggregation_interval
|
||||||
|
"AND (:today - dtmcreated) > :interval " .
|
||||||
// Ignore threads when operator does not start chat
|
// Ignore threads when operator does not start chat
|
||||||
"AND dtmchatstarted <> 0 " .
|
"AND dtmchatstarted <> 0 " .
|
||||||
// Ignore all invitations
|
// Ignore all invitations
|
||||||
@ -159,6 +166,7 @@ function calculate_thread_statistics() {
|
|||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today,
|
':today' => $today,
|
||||||
|
':interval' => $interval,
|
||||||
':not_invited' => Thread::INVITATION_NOT_INVITED
|
':not_invited' => Thread::INVITATION_NOT_INVITED
|
||||||
),
|
),
|
||||||
array('return_rows' => Database::RETURN_ALL_ROWS)
|
array('return_rows' => Database::RETURN_ALL_ROWS)
|
||||||
@ -173,15 +181,16 @@ function calculate_thread_statistics() {
|
|||||||
|
|
||||||
// Get invitation info
|
// Get invitation info
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT (FLOOR(dtmcreated / (24*60*60)) * 24*60*60) AS date, " .
|
"SELECT (FLOOR(dtmcreated / :interval) * :interval) AS date, " .
|
||||||
"COUNT(*) AS invitations_sent, " .
|
"COUNT(*) AS invitations_sent, " .
|
||||||
"SUM(invitationstate = :invitation_accepted) AS invitations_accepted, " .
|
"SUM(invitationstate = :invitation_accepted) AS invitations_accepted, " .
|
||||||
"SUM(invitationstate = :invitation_rejected) AS invitations_rejected, " .
|
"SUM(invitationstate = :invitation_rejected) AS invitations_rejected, " .
|
||||||
"SUM(invitationstate = :invitation_ignored) AS invitations_ignored " .
|
"SUM(invitationstate = :invitation_ignored) AS invitations_ignored " .
|
||||||
"FROM {chatthread} " .
|
"FROM {chatthread} " .
|
||||||
"WHERE (dtmcreated - :start) > 24*60*60 " .
|
"WHERE (dtmcreated - :start) > :interval " .
|
||||||
// Calculate statistics only for threads that older than one day
|
// Calculate statistics only for threads that older than
|
||||||
"AND (:today - dtmcreated) > 24*60*60 " .
|
// statistics_aggregation_interval
|
||||||
|
"AND (:today - dtmcreated) > :interval " .
|
||||||
"AND (invitationstate = :invitation_accepted " .
|
"AND (invitationstate = :invitation_accepted " .
|
||||||
"OR invitationstate = :invitation_rejected " .
|
"OR invitationstate = :invitation_rejected " .
|
||||||
"OR invitationstate = :invitation_ignored) " .
|
"OR invitationstate = :invitation_ignored) " .
|
||||||
@ -189,6 +198,7 @@ function calculate_thread_statistics() {
|
|||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today,
|
':today' => $today,
|
||||||
|
':interval' => $interval,
|
||||||
':invitation_accepted' => Thread::INVITATION_ACCEPTED,
|
':invitation_accepted' => Thread::INVITATION_ACCEPTED,
|
||||||
':invitation_rejected' => Thread::INVITATION_REJECTED,
|
':invitation_rejected' => Thread::INVITATION_REJECTED,
|
||||||
':invitation_ignored' => Thread::INVITATION_IGNORED
|
':invitation_ignored' => Thread::INVITATION_IGNORED
|
||||||
@ -271,6 +281,8 @@ function calculate_operator_statistics() {
|
|||||||
$db = Database::getInstance();
|
$db = Database::getInstance();
|
||||||
$db_throw_exceptions = $db->throwExeptions(true);
|
$db_throw_exceptions = $db->throwExeptions(true);
|
||||||
|
|
||||||
|
$interval = Settings::get('statistics_aggregation_interval');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Start transaction
|
// Start transaction
|
||||||
$db->query('START TRANSACTION');
|
$db->query('START TRANSACTION');
|
||||||
@ -283,12 +295,12 @@ function calculate_operator_statistics() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$start = empty($result['start']) ? 0 : $result['start'];
|
$start = empty($result['start']) ? 0 : $result['start'];
|
||||||
$today = floor(time() / (24*60*60)) * 24*60*60;
|
$today = floor(time() / $interval) * $interval;
|
||||||
|
|
||||||
// Caclculate statistics
|
// Caclculate statistics
|
||||||
// Get base operator's info
|
// Get base operator's info
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT (FLOOR(m.dtmcreated / (24*60*60)) * 24*60*60) AS date, " .
|
"SELECT (FLOOR(m.dtmcreated / :interval) * :interval) AS date, " .
|
||||||
"m.agentId AS operator_id, " .
|
"m.agentId AS operator_id, " .
|
||||||
"COUNT(distinct m.threadid) AS threads, " .
|
"COUNT(distinct m.threadid) AS threads, " .
|
||||||
"COUNT(m.messageid) AS messages, " .
|
"COUNT(m.messageid) AS messages, " .
|
||||||
@ -299,9 +311,10 @@ function calculate_operator_statistics() {
|
|||||||
"FROM {chatmessage} m, {chatthread} t " .
|
"FROM {chatmessage} m, {chatthread} t " .
|
||||||
"WHERE m.ikind = :kind_agent " .
|
"WHERE m.ikind = :kind_agent " .
|
||||||
"AND m.threadid = t.threadid " .
|
"AND m.threadid = t.threadid " .
|
||||||
"AND (m.dtmcreated - :start) > 24*60*60 " .
|
"AND (m.dtmcreated - :start) > :interval " .
|
||||||
// Calculate statistics only for messages that older one day
|
// Calculate statistics only for messages that older
|
||||||
"AND (:today - m.dtmcreated) > 24*60*60 " .
|
// statistics_aggregation_interval
|
||||||
|
"AND (:today - m.dtmcreated) > :interval " .
|
||||||
// Ignore not accepted invitations
|
// Ignore not accepted invitations
|
||||||
"AND (t.invitationstate = :not_invited " .
|
"AND (t.invitationstate = :not_invited " .
|
||||||
"OR t.invitationstate = :invitation_accepted) " .
|
"OR t.invitationstate = :invitation_accepted) " .
|
||||||
@ -309,6 +322,7 @@ function calculate_operator_statistics() {
|
|||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today,
|
':today' => $today,
|
||||||
|
':interval' => $interval,
|
||||||
':not_invited' => Thread::INVITATION_NOT_INVITED,
|
':not_invited' => Thread::INVITATION_NOT_INVITED,
|
||||||
':invitation_accepted' => Thread::INVITATION_ACCEPTED,
|
':invitation_accepted' => Thread::INVITATION_ACCEPTED,
|
||||||
':kind_agent' => Thread::KIND_AGENT
|
':kind_agent' => Thread::KIND_AGENT
|
||||||
@ -325,16 +339,17 @@ function calculate_operator_statistics() {
|
|||||||
|
|
||||||
// Get info about invitations
|
// Get info about invitations
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT (FLOOR(dtmcreated / (24*60*60)) * 24*60*60) AS date, " .
|
"SELECT (FLOOR(dtmcreated / :interval) * :interval) AS date, " .
|
||||||
"agentId as operator_id, " .
|
"agentId as operator_id, " .
|
||||||
"COUNT(threadid) AS invitations_sent, " .
|
"COUNT(threadid) AS invitations_sent, " .
|
||||||
"SUM(invitationstate = :invitation_accepted) AS invitations_accepted, " .
|
"SUM(invitationstate = :invitation_accepted) AS invitations_accepted, " .
|
||||||
"SUM(invitationstate = :invitation_rejected) AS invitations_rejected, " .
|
"SUM(invitationstate = :invitation_rejected) AS invitations_rejected, " .
|
||||||
"SUM(invitationstate = :invitation_ignored) AS invitations_ignored " .
|
"SUM(invitationstate = :invitation_ignored) AS invitations_ignored " .
|
||||||
"FROM {chatthread} " .
|
"FROM {chatthread} " .
|
||||||
"WHERE (dtmcreated - :start) > 24*60*60 " .
|
"WHERE (dtmcreated - :start) > :interval " .
|
||||||
// Calculate statistics only for threads that older than one day
|
// Calculate statistics only for threads that older than
|
||||||
"AND (:today - dtmcreated) > 24*60*60 " .
|
// statistics_aggregation_interval
|
||||||
|
"AND (:today - dtmcreated) > :interval " .
|
||||||
// Check if thread has related operator
|
// Check if thread has related operator
|
||||||
"AND agentId != 0 " .
|
"AND agentId != 0 " .
|
||||||
// Ignore not accepted invitations
|
// Ignore not accepted invitations
|
||||||
@ -345,6 +360,7 @@ function calculate_operator_statistics() {
|
|||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today,
|
':today' => $today,
|
||||||
|
':interval' => $interval,
|
||||||
':invitation_accepted' => Thread::INVITATION_ACCEPTED,
|
':invitation_accepted' => Thread::INVITATION_ACCEPTED,
|
||||||
':invitation_rejected' => Thread::INVITATION_REJECTED,
|
':invitation_rejected' => Thread::INVITATION_REJECTED,
|
||||||
':invitation_ignored' => Thread::INVITATION_IGNORED
|
':invitation_ignored' => Thread::INVITATION_IGNORED
|
||||||
@ -422,6 +438,8 @@ function calculate_page_statistics() {
|
|||||||
$db = Database::getInstance();
|
$db = Database::getInstance();
|
||||||
$db_throw_exceptions = $db->throwExeptions(true);
|
$db_throw_exceptions = $db->throwExeptions(true);
|
||||||
|
|
||||||
|
$interval = Settings::get('statistics_aggregation_interval');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Start transaction
|
// Start transaction
|
||||||
$db->query('START TRANSACTION');
|
$db->query('START TRANSACTION');
|
||||||
@ -434,24 +452,25 @@ function calculate_page_statistics() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$start = empty($result['start']) ? 0 : $result['start'];
|
$start = empty($result['start']) ? 0 : $result['start'];
|
||||||
$today = floor(time() / (24*60*60)) * 24*60*60;
|
$today = floor(time() / $interval) * $interval;
|
||||||
|
|
||||||
$statistics = array();
|
$statistics = array();
|
||||||
|
|
||||||
// Calculate statistics
|
// Calculate statistics
|
||||||
// Get main pages info
|
// Get main pages info
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT FLOOR(visittime / (24*60*60)) * 24*60*60 AS date, " .
|
"SELECT FLOOR(visittime / :interval) * :interval AS date, " .
|
||||||
"address, " .
|
"address, " .
|
||||||
"COUNT(DISTINCT pageid) AS visits " .
|
"COUNT(DISTINCT pageid) AS visits " .
|
||||||
"FROM {visitedpage} ".
|
"FROM {visitedpage} ".
|
||||||
"WHERE calculated = 0 " .
|
"WHERE calculated = 0 " .
|
||||||
"AND (visittime - :start) > 24*60*60 " .
|
"AND (visittime - :start) > :interval " .
|
||||||
"AND (:today - visittime) > 24*60*60 " .
|
"AND (:today - visittime) > :interval " .
|
||||||
"GROUP BY date, address",
|
"GROUP BY date, address",
|
||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today
|
':today' => $today,
|
||||||
|
':interval' => $interval
|
||||||
),
|
),
|
||||||
array('return_rows' => Database::RETURN_ALL_ROWS)
|
array('return_rows' => Database::RETURN_ALL_ROWS)
|
||||||
);
|
);
|
||||||
@ -465,7 +484,7 @@ function calculate_page_statistics() {
|
|||||||
|
|
||||||
// Get total chats count
|
// Get total chats count
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT FLOOR(p.visittime / (24*60*60)) * 24*60*60 AS date, " .
|
"SELECT FLOOR(p.visittime / :interval) * :interval AS date, " .
|
||||||
"p.address AS address, " .
|
"p.address AS address, " .
|
||||||
"COUNT(DISTINCT t.threadid) AS chats " .
|
"COUNT(DISTINCT t.threadid) AS chats " .
|
||||||
"FROM {visitedpage} p, {chatthread} t, " .
|
"FROM {visitedpage} p, {chatthread} t, " .
|
||||||
@ -480,8 +499,8 @@ function calculate_page_statistics() {
|
|||||||
"AND t.threadid = tmp.threadid " .
|
"AND t.threadid = tmp.threadid " .
|
||||||
"AND tmp.msgs > 0 " .
|
"AND tmp.msgs > 0 " .
|
||||||
"AND t.dtmchatstarted <> 0 " .
|
"AND t.dtmchatstarted <> 0 " .
|
||||||
"AND (p.visittime - :start) > 24*60*60 " .
|
"AND (p.visittime - :start) > :interval " .
|
||||||
"AND (:today - p.visittime) > 24*60*60 " .
|
"AND (:today - p.visittime) > :interval " .
|
||||||
"AND DATE(FROM_UNIXTIME(p.visittime)) " .
|
"AND DATE(FROM_UNIXTIME(p.visittime)) " .
|
||||||
"= DATE(FROM_UNIXTIME(t.dtmcreated)) " .
|
"= DATE(FROM_UNIXTIME(t.dtmcreated)) " .
|
||||||
"AND (t.invitationstate = :not_invited " .
|
"AND (t.invitationstate = :not_invited " .
|
||||||
@ -490,6 +509,7 @@ function calculate_page_statistics() {
|
|||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today,
|
':today' => $today,
|
||||||
|
':interval' => $interval,
|
||||||
':not_invited' => Thread::INVITATION_NOT_INVITED,
|
':not_invited' => Thread::INVITATION_NOT_INVITED,
|
||||||
':invitation_accepted' => Thread::INVITATION_ACCEPTED,
|
':invitation_accepted' => Thread::INVITATION_ACCEPTED,
|
||||||
':kind_agent' => Thread::KIND_AGENT,
|
':kind_agent' => Thread::KIND_AGENT,
|
||||||
@ -507,14 +527,14 @@ function calculate_page_statistics() {
|
|||||||
|
|
||||||
// Get info about accepted invitations
|
// Get info about accepted invitations
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT FLOOR(p.visittime / (24*60*60)) * 24*60*60 AS date, " .
|
"SELECT FLOOR(p.visittime / :interval) * :interval AS date, " .
|
||||||
"p.address AS address, " .
|
"p.address AS address, " .
|
||||||
"COUNT(DISTINCT t.threadid) AS invitations_accepted " .
|
"COUNT(DISTINCT t.threadid) AS invitations_accepted " .
|
||||||
"FROM {visitedpage} p, {chatthread} t " .
|
"FROM {visitedpage} p, {chatthread} t " .
|
||||||
"WHERE t.referer = p.address " .
|
"WHERE t.referer = p.address " .
|
||||||
"AND p.calculated = 0 " .
|
"AND p.calculated = 0 " .
|
||||||
"AND (p.visittime - :start) > 24*60*60 " .
|
"AND (p.visittime - :start) > :interval " .
|
||||||
"AND (:today - p.visittime) > 24*60*60 " .
|
"AND (:today - p.visittime) > :interval " .
|
||||||
"AND DATE(FROM_UNIXTIME(p.visittime)) " .
|
"AND DATE(FROM_UNIXTIME(p.visittime)) " .
|
||||||
"= DATE(FROM_UNIXTIME(t.dtmcreated)) " .
|
"= DATE(FROM_UNIXTIME(t.dtmcreated)) " .
|
||||||
"AND t.invitationstate = :invitation_accepted " .
|
"AND t.invitationstate = :invitation_accepted " .
|
||||||
@ -522,6 +542,7 @@ function calculate_page_statistics() {
|
|||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today,
|
':today' => $today,
|
||||||
|
':interval' => $interval,
|
||||||
':invitation_accepted' => Thread::INVITATION_ACCEPTED
|
':invitation_accepted' => Thread::INVITATION_ACCEPTED
|
||||||
),
|
),
|
||||||
array('return_rows' => Database::RETURN_ALL_ROWS)
|
array('return_rows' => Database::RETURN_ALL_ROWS)
|
||||||
@ -536,14 +557,14 @@ function calculate_page_statistics() {
|
|||||||
|
|
||||||
// Get info about rejected invitations
|
// Get info about rejected invitations
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT FLOOR(p.visittime / (24*60*60)) * 24*60*60 AS date, " .
|
"SELECT FLOOR(p.visittime / :interval) * :interval AS date, " .
|
||||||
"p.address AS address, " .
|
"p.address AS address, " .
|
||||||
"COUNT(DISTINCT t.threadid) AS invitations_rejected " .
|
"COUNT(DISTINCT t.threadid) AS invitations_rejected " .
|
||||||
"FROM {visitedpage} p, {chatthread} t " .
|
"FROM {visitedpage} p, {chatthread} t " .
|
||||||
"WHERE t.referer = p.address " .
|
"WHERE t.referer = p.address " .
|
||||||
"AND p.calculated = 0 " .
|
"AND p.calculated = 0 " .
|
||||||
"AND (p.visittime - :start) > 24*60*60 " .
|
"AND (p.visittime - :start) > :interval " .
|
||||||
"AND (:today - p.visittime) > 24*60*60 " .
|
"AND (:today - p.visittime) > :interval " .
|
||||||
"AND DATE(FROM_UNIXTIME(p.visittime)) " .
|
"AND DATE(FROM_UNIXTIME(p.visittime)) " .
|
||||||
"= DATE(FROM_UNIXTIME(t.dtmcreated)) " .
|
"= DATE(FROM_UNIXTIME(t.dtmcreated)) " .
|
||||||
"AND t.invitationstate = :invitation_rejected " .
|
"AND t.invitationstate = :invitation_rejected " .
|
||||||
@ -551,6 +572,7 @@ function calculate_page_statistics() {
|
|||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today,
|
':today' => $today,
|
||||||
|
':interval' => $interval,
|
||||||
':invitation_rejected' => Thread::INVITATION_REJECTED
|
':invitation_rejected' => Thread::INVITATION_REJECTED
|
||||||
),
|
),
|
||||||
array('return_rows' => Database::RETURN_ALL_ROWS)
|
array('return_rows' => Database::RETURN_ALL_ROWS)
|
||||||
@ -565,14 +587,14 @@ function calculate_page_statistics() {
|
|||||||
|
|
||||||
// Get info about ignored invitations
|
// Get info about ignored invitations
|
||||||
$db_results = $db->query(
|
$db_results = $db->query(
|
||||||
"SELECT FLOOR(p.visittime / (24*60*60)) * 24*60*60 AS date, " .
|
"SELECT FLOOR(p.visittime / :interval) * :interval AS date, " .
|
||||||
"p.address AS address, " .
|
"p.address AS address, " .
|
||||||
"COUNT(DISTINCT t.threadid) AS invitations_ignored " .
|
"COUNT(DISTINCT t.threadid) AS invitations_ignored " .
|
||||||
"FROM {visitedpage} p, {chatthread} t " .
|
"FROM {visitedpage} p, {chatthread} t " .
|
||||||
"WHERE t.referer = p.address " .
|
"WHERE t.referer = p.address " .
|
||||||
"AND p.calculated = 0 " .
|
"AND p.calculated = 0 " .
|
||||||
"AND (p.visittime - :start) > 24*60*60 " .
|
"AND (p.visittime - :start) > :interval " .
|
||||||
"AND (:today - p.visittime) > 24*60*60 " .
|
"AND (:today - p.visittime) > :interval " .
|
||||||
"AND DATE(FROM_UNIXTIME(p.visittime)) " .
|
"AND DATE(FROM_UNIXTIME(p.visittime)) " .
|
||||||
"= DATE(FROM_UNIXTIME(t.dtmcreated)) " .
|
"= DATE(FROM_UNIXTIME(t.dtmcreated)) " .
|
||||||
"AND t.invitationstate = :invitation_ignored " .
|
"AND t.invitationstate = :invitation_ignored " .
|
||||||
@ -580,6 +602,7 @@ function calculate_page_statistics() {
|
|||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
':today' => $today,
|
':today' => $today,
|
||||||
|
':interval' => $interval,
|
||||||
':invitation_ignored' => Thread::INVITATION_IGNORED
|
':invitation_ignored' => Thread::INVITATION_IGNORED
|
||||||
),
|
),
|
||||||
array('return_rows' => Database::RETURN_ALL_ROWS)
|
array('return_rows' => Database::RETURN_ALL_ROWS)
|
||||||
@ -632,10 +655,11 @@ function calculate_page_statistics() {
|
|||||||
// Mark all visited pages as 'calculated'
|
// Mark all visited pages as 'calculated'
|
||||||
$db->query(
|
$db->query(
|
||||||
"UPDATE {visitedpage} SET calculated = 1 " .
|
"UPDATE {visitedpage} SET calculated = 1 " .
|
||||||
"WHERE (:today - visittime) > 24*60*60 " .
|
"WHERE (:today - visittime) > :interval " .
|
||||||
"AND calculated = 0",
|
"AND calculated = 0",
|
||||||
array(
|
array(
|
||||||
':today' => $today
|
':today' => $today,
|
||||||
|
':interval' => $interval
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -562,6 +562,8 @@ settings.saved=Changes saved
|
|||||||
settings.sendmessagekey=Send messages with:
|
settings.sendmessagekey=Send messages with:
|
||||||
settings.show_online_operators.description=Can slow down the update rate of the list
|
settings.show_online_operators.description=Can slow down the update rate of the list
|
||||||
settings.show_online_operators=Show online operators on "List of awaiting visitors" page
|
settings.show_online_operators=Show online operators on "List of awaiting visitors" page
|
||||||
|
settings.statistics_aggregation_interval=Statistics aggregation interval
|
||||||
|
settings.statistics_aggregation_interval.description=Specify interval for statistics aggregation in seconds. Default is 86400 (one day)
|
||||||
settings.survey.askgroup.description=Show/hide department selection field in the survey
|
settings.survey.askgroup.description=Show/hide department selection field in the survey
|
||||||
settings.survey.askgroup=Allows a visitor to choose department/group
|
settings.survey.askgroup=Allows a visitor to choose department/group
|
||||||
settings.survey.askmail.description=Show/hide email field in the survey
|
settings.survey.askmail.description=Show/hide email field in the survey
|
||||||
|
@ -561,6 +561,8 @@ settings.saved=
|
|||||||
settings.sendmessagekey=Посылать сообщение по:
|
settings.sendmessagekey=Посылать сообщение по:
|
||||||
settings.show_online_operators.description=Может замедлить обновление списка
|
settings.show_online_operators.description=Может замедлить обновление списка
|
||||||
settings.show_online_operators=Показывать доступных операторов на странице ожидающих посетителей
|
settings.show_online_operators=Показывать доступных операторов на странице ожидающих посетителей
|
||||||
|
settings.statistics_aggregation_interval=Èíòåðâàë ñóììèðîâàíèÿ ñòàòèñòèêè
|
||||||
|
settings.statistics_aggregation_interval.description=Óêàæèòå èíòåðâàë äëÿ ñóììèðîâàíèÿ ñòàòèñòèêè â ñåêóíäàõ. Ïî óìîë÷àíèþ, 86400 ñåêóíä (îäèí äåíü)
|
||||||
settings.survey.askgroup.description=Показать/спрятать выбор группы в диалоге перед началом чата
|
settings.survey.askgroup.description=Показать/спрятать выбор группы в диалоге перед началом чата
|
||||||
settings.survey.askgroup=Позволять посетителю выбирать группу операторов
|
settings.survey.askgroup=Позволять посетителю выбирать группу операторов
|
||||||
settings.survey.askmail.description=Показать/спрятать поле ввода адреса электронной почты
|
settings.survey.askmail.description=Показать/спрятать поле ввода адреса электронной почты
|
||||||
|
@ -29,7 +29,7 @@ $options = array(
|
|||||||
'online_timeout', 'updatefrequency_operator', 'updatefrequency_chat',
|
'online_timeout', 'updatefrequency_operator', 'updatefrequency_chat',
|
||||||
'max_connections_from_one_host',
|
'max_connections_from_one_host',
|
||||||
'updatefrequency_tracking', 'visitors_limit', 'invitation_lifetime',
|
'updatefrequency_tracking', 'visitors_limit', 'invitation_lifetime',
|
||||||
'tracking_lifetime', 'thread_lifetime' );
|
'tracking_lifetime', 'thread_lifetime', 'statistics_aggregation_interval');
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
foreach ($options as $opt) {
|
foreach ($options as $opt) {
|
||||||
@ -62,6 +62,11 @@ if (isset($_POST['onlinetimeout'])) {
|
|||||||
$errors[] = getlocal("settings.wrong.threadlifetime");
|
$errors[] = getlocal("settings.wrong.threadlifetime");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$params['statistics_aggregation_interval'] = getparam('statistics_aggregation_interval');
|
||||||
|
if (!is_numeric($params['statistics_aggregation_interval'])) {
|
||||||
|
$errors[] = wrong_field("settings.statistics_aggregation_interval");
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings::get('enabletracking')) {
|
if (Settings::get('enabletracking')) {
|
||||||
|
|
||||||
$params['updatefrequency_tracking'] = getparam('frequencytracking');
|
$params['updatefrequency_tracking'] = getparam('frequencytracking');
|
||||||
@ -101,6 +106,7 @@ $page['formfrequencyoperator'] = $params['updatefrequency_operator'];
|
|||||||
$page['formfrequencychat'] = $params['updatefrequency_chat'];
|
$page['formfrequencychat'] = $params['updatefrequency_chat'];
|
||||||
$page['formonehostconnections'] = $params['max_connections_from_one_host'];
|
$page['formonehostconnections'] = $params['max_connections_from_one_host'];
|
||||||
$page['formthreadlifetime'] = $params['thread_lifetime'];
|
$page['formthreadlifetime'] = $params['thread_lifetime'];
|
||||||
|
$page['formstatistics_aggregation_interval'] = $params['statistics_aggregation_interval'];
|
||||||
|
|
||||||
if (Settings::get('enabletracking')) {
|
if (Settings::get('enabletracking')) {
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ if ($statisticstype == 'bydate') {
|
|||||||
"FROM {chatthreadstatistics} s " .
|
"FROM {chatthreadstatistics} s " .
|
||||||
"WHERE s.date >= :start " .
|
"WHERE s.date >= :start " .
|
||||||
"AND s.date < :end " .
|
"AND s.date < :end " .
|
||||||
|
"GROUP BY DATE(FROM_UNIXTIME(date)) " .
|
||||||
"ORDER BY s.date DESC",
|
"ORDER BY s.date DESC",
|
||||||
array(
|
array(
|
||||||
':start' => $start,
|
':start' => $start,
|
||||||
|
@ -86,6 +86,15 @@ require_once('inc_errors.php');
|
|||||||
<br clear="all"/>
|
<br clear="all"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<div class="flabel"><?php echo getlocal('settings.statistics_aggregation_interval') ?></div>
|
||||||
|
<div class="fvalue">
|
||||||
|
<input type="text" name="statistics_aggregation_interval" size="40" value="<?php echo form_value('statistics_aggregation_interval') ?>" class="formauth"/>
|
||||||
|
</div>
|
||||||
|
<div class="fdescr"> — <?php echo getlocal('settings.statistics_aggregation_interval.description') ?></div>
|
||||||
|
<br clear="all"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php if ($page['enabletracking']) { ?>
|
<?php if ($page['enabletracking']) { ?>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="flabel"><?php echo getlocal('settings.frequencytracking') ?></div>
|
<div class="flabel"><?php echo getlocal('settings.frequencytracking') ?></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user