Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// HOURLY VENDOR LOG
- $nearHour = floor(time() / 3600) * 3600;
- $query = "SELECT last_id FROM vendor_hourly_log ORDER BY id DESC LIMIT 1";
- $last_id = Lib_MysqlManage::simpleResult(Lib_MysqlManage::makeQuery($query));
- $query = "SELECT hour_stamp FROM vendor_hourly_log ORDER BY id DESC LIMIT 1";
- $last_hour_stamp = Lib_MysqlManage::simpleResult(Lib_MysqlManage::makeQuery($query));
- $query = "INSERT INTO vendor_hourly_log (vendor_hourly_log.hour_stamp, vendor_hourly_log.vendor_id, vendor_hourly_log.printed_all, vendor_hourly_log.money_amount, vendor_hourly_log.hopper_amount, vendor_hourly_log.promocodes_amount, vendor_hourly_log.all_sessions, vendor_hourly_log.printed_sessions, vendor_hourly_log.last_id ) SELECT floor(session_created_time / 3600) * 3600 as my_date, vendor_id, SUM(printed_all) as printed_all, SUM(money_amount) as money_amount, SUM(hopper_amount) as hopper_amount , SUM(promocodes_amount) as promocodes_amount, COUNT(*) as all_sessions, SUM( printed_all>0 ) as printed_sessions, MAX(id) as last_id FROM vendor_log WHERE vendor_log.id > " . $last_id . " AND vendor_log.session_created_time < " . $nearHour . " GROUP BY vendor_log.vendor_id, my_date ORDER BY vendor_log.session_created_time ";
- Lib_MysqlManage::makeQuery($query);
- $query = "UPDATE vendor_hourly_log as temp_vendor_hourly_log INNER JOIN(SELECT floor(timestamp / 3600) * 3600 as my_date, vendor_id, COUNT(*) as uptime_count FROM vendors_uptime WHERE vendors_uptime.timestamp >= " . $last_hour_stamp . " GROUP BY vendors_uptime.vendor_id, my_date ORDER BY vendors_uptime.id ) as src SET temp_vendor_hourly_log.uptime = src.uptime_count WHERE temp_vendor_hourly_log.vendor_id = src.vendor_id AND temp_vendor_hourly_log.hour_stamp = src.my_date";
- Lib_MysqlManage::makeQuery($query);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement