Skip to content

Instantly share code, notes, and snippets.

@Ulv
Created November 13, 2013 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ulv/7447109 to your computer and use it in GitHub Desktop.
Save Ulv/7447109 to your computer and use it in GitHub Desktop.
masterovoy clear db queries & recalculate stats
$queries = array(
'delete from `s_robots_log` where YEAR(dtlabel) <> YEAR(CURDATE())',
'delete from `s_visits_log` where YEAR(dtlabel) <> YEAR(CURDATE())',
'truncate table `s_robots_stat`',
// 'truncate table `s_visits_stat`',
'truncate table a_ua_ranges',
'truncate table a_log',
'truncate table a_http_error',
// restore stats
'insert into s_robots_stat (statdate, dtmonth, dtday, hosts, hits) select date(dtlabel),dtmonth, '.
'dtday,count(logid), count(distinct ip) from s_robots_log group by dtmonth,dtday',
'insert into s_visits_stat (statdate, dtmonth, dtday, hosts, hits) '.
'select date(dtlabel),dtmonth,dtday,count(logid) as hits, count(distinct ip) as '.
'hosts from s_visits_log group by dtmonth,dtday'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment