Permalink
Browse files

mdoify redis service

Reviewers: nan.li

Reviewed By: nan.li

Differential Revision: http://pha.cobub.cn/D149
  • Loading branch information...
qinghai.zhang
qinghai.zhang committed Dec 25, 2015
1 parent d942dba commit 43a81c625912a57117d5704c18dca9ec12d80f9c
@@ -39,6 +39,7 @@ class Activitylog extends CI_Model
function Activitylog()
{
parent::__construct();
$this -> load -> model("redis_service/processor");
$this -> load -> library('redis');
}
@@ -52,13 +53,21 @@ function Activitylog()
*/
function addActivitylog($activitylog)
{
$data = array('appkey' => $activitylog -> appkey, 'session_id' => $activitylog -> session_id, 'start_millis' => $activitylog -> start_millis, 'end_millis' => $activitylog -> end_millis, 'activities' => $activitylog -> activities, 'duration' => $activitylog -> duration, 'version' => isset($activitylog -> version) ? $activitylog -> version : '');
$data = array('appkey' => $activitylog -> appkey,
'session_id' => $activitylog->session_id,
'start_millis' => $activitylog->start_millis,
'end_millis' => $activitylog-> end_millis,
'activities' => $activitylog->activities,
'duration' => $activitylog-> duration,
'version'=>isset($activitylog-> version) ? $activitylog->version : '');
$this -> redis -> lpush("razor_clientusinglogs", serialize($data));
$productId = $this -> utility -> getProductIdByKey($activitylog -> appkey);
$key = "razor_r_ac_p_" . $productId . "_" . date('Y-m-d-H-i-s', time());
$this -> redis -> hset($key, array("$activitylog->activities" => 1));
$this -> redis -> hset($key, array($activitylog->activities => 1));
$this -> redis -> expire($key, 30 * 60);
$this -> processor -> process();
}
@@ -40,6 +40,7 @@ function Clientdata()
$this -> load -> model('utility');
$this -> load -> database();
$this -> load -> helper("date");
$this -> load -> model("redis_service/processor");
$this -> load -> library('redis');
$this -> load -> model('lbs_service/google', 'google');
$this -> load -> model('lbs_service/ipinfodb', 'ipinfodb');
@@ -60,9 +61,7 @@ function addClientdata($clientdata)
$productId = $this -> utility -> getProductIdByKey($clientdata -> appkey);
//For realtime User sessions
$key = "razor_r_u_p_" . $productId . "_" . date('Y-m-d-H-i', time());
$this -> redis -> hset($key, array($data["deviceid"] => $productId));
$this -> redis -> expire($key, 30 * 60);
$ip = $this -> utility -> getOnlineIP();
$nowtime = date('Y-m-d H:i:s');
if (isset($clientdata -> time)) {
@@ -71,8 +70,36 @@ function addClientdata($clientdata)
$nowtime = date('Y-m-d H:i:s');
}
}
$data = array('productkey' => $clientdata -> appkey, 'platform' => $clientdata -> platform, 'osversion' => $clientdata -> os_version, 'language' => $clientdata -> language, 'deviceid' => $clientdata -> deviceid, 'resolution' => $clientdata -> resolution, 'ismobiledevice' => isset($clientdata -> ismobiledevice) ? $clientdata -> ismobiledevice : '', 'devicename' => isset($clientdata -> devicename) ? $clientdata -> devicename : 'unknown', 'defaultbrowser' => isset($clientdata -> defaultbrowser) ? $clientdata -> defaultbrowser : '', 'javasupport' => isset($clientdata -> javasupport) ? $clientdata -> javasupport : '', 'flashversion' => isset($clientdata -> flashversion) ? $clientdata -> flashversion : '', 'modulename' => isset($clientdata -> modulename) ? $clientdata -> modulename : '', 'imei' => isset($clientdata -> imei) ? $clientdata -> imei : '', 'imsi' => isset($clientdata -> imsi) ? $clientdata -> imsi : '', 'havegps' => isset($clientdata -> havegps) ? $clientdata -> havegps : '', 'havebt' => isset($clientdata -> havebt) ? $clientdata -> havebt : '', 'havewifi' => isset($clientdata -> havewifi) ? $clientdata -> havewifi : '', 'havegravity' => isset($clientdata -> havegravity) ? $clientdata -> havegravity : '', 'wifimac' => isset($clientdata -> wifimac) ? $clientdata -> wifimac : '', 'version' => isset($clientdata -> version) ? $clientdata -> version : '', 'network' => isset($clientdata -> network) ? $clientdata -> network : '', 'latitude' => isset($clientdata -> latitude) ? $clientdata -> latitude : '', 'longitude' => isset($clientdata -> longitude) ? $clientdata -> longitude : '', 'isjailbroken' => isset($clientdata -> isjailbroken) ? $clientdata -> isjailbroken : 0, 'date' => $nowtime, 'service_supplier' => isset($clientdata -> mccmnc) ? $clientdata -> mccmnc : '0', 'clientip' => $ip);
$latitude = isset($clientdata -> latitude) ? $clientdata -> latitude : '';
$data = array('productkey' => $clientdata -> appkey,
'platform' => $clientdata -> platform,
'osversion' => $clientdata -> os_version,
'language' => $clientdata -> language,
'deviceid'=>$clientdata->deviceid,
'resolution' => $clientdata -> resolution,
'ismobiledevice' => isset($clientdata -> ismobiledevice) ? $clientdata -> ismobiledevice : '',
'devicename' => isset($clientdata -> devicename) ? $clientdata -> devicename:'unknown',
'defaultbrowser' =>isset($clientdata -> defaultbrowser) ? $clientdata -> defaultbrowser : '',
'javasupport' => isset($clientdata -> javasupport) ? $clientdata -> javasupport : '',
'flashversion' =>isset($clientdata -> flashversion) ? $clientdata -> flashversion : '',
'modulename' => isset($clientdata -> modulename) ? $clientdata -> modulename : '',
'imei' => isset($clientdata -> imei) ? $clientdata -> imei : '',
'imsi' => isset($clientdata -> imsi) ? $clientdata -> imsi : '',
'havegps' => isset($clientdata -> havegps) ? $clientdata -> havegps : '',
'havebt' =>isset($clientdata -> havebt) ? $clientdata -> havebt : '',
'havewifi' => isset($clientdata -> havewifi) ? $clientdata -> havewifi : '',
'havegravity' =>isset($clientdata -> havegravity) ? $clientdata -> havegravity : '',
'wifimac' =>isset($clientdata -> wifimac) ? $clientdata -> wifimac : '',
'version' => isset($clientdata -> version) ? $clientdata -> version : '',
'network' => isset($clientdata -> network) ? $clientdata -> network : '',
'latitude' => isset($clientdata -> latitude) ? $clientdata -> latitude : '',
'longitude' => isset($clientdata -> longitude) ? $clientdata -> longitude : '',
'isjailbroken' => isset($clientdata -> isjailbroken) ? $clientdata -> isjailbroken : 0,
'date' => $nowtime,
'service_supplier' => isset($clientdata -> mccmnc) ? $clientdata -> mccmnc : '0',
'clientip' => $ip);
$latitude = isset($clientdata -> latitude) ? $clientdata -> latitude : '';
$choose = $this -> config -> item('get_geographical');
$data["country"] = 'unknown';
$data["region"] = 'unknown';
@@ -93,6 +120,13 @@ function addClientdata($clientdata)
$data['region'] = $this->iplibrary->getRegion();
$data['city'] = $this->iplibrary->getCity();
}
$this -> redis -> lpush("razor_clientdata", serialize($data));
$this -> redis -> hset($key, array($data["deviceid"] => $productId));
$this -> redis -> expire($key, 30 * 60);
//For realtime areas
$key = "razor_r_arc_p_" . $productId . "_c_" . $data["country"] . "_" . date('Y-m-d-H-i', time());
$this -> redis -> hset($key, array($data["country"] => $productId));
@@ -108,8 +142,7 @@ function addClientdata($clientdata)
//$timezonestimestamp = gmt_to_local(local_to_gmt(), $this->config->item('timezones'));
//$timezonestime = date ( 'Y-m-d H:i:m', $timezonestimestamp );
$this -> redis -> lpush("razor_clientdata", serialize($data));
$this -> processor -> process();
}
@@ -60,7 +60,7 @@ function process()
$this -> processItems("razor_errors", "errorlog", "appkey");
$this -> processItems("razor_clientdata", "clientdata", "productkey");
$this -> processItems("razor_clientusinglogs", "clientusinglog", "appkey");
$this -> processItems("razor_usertag", "device_tag", "productkey");
$this -> processItems("razor_usertag", "device_tag", "appkey");
}
} else {
$timestamp = date('Y-m-d H:i:s', time());
@@ -39,6 +39,7 @@ function Userlog()
{
parent::__construct();
$this -> load -> database();
$this -> load -> model("redis_service/processor");
$this -> load -> library('redis');
}
@@ -39,6 +39,7 @@ function __construct()
{
parent::__construct();
$this -> load -> library('redis');
$this -> load -> model("redis_service/processor");
}
/**
@@ -54,7 +55,9 @@ function addUserTag($content)
$this -> load -> model('servicepublicclass/posttagpublic', 'posttagpublic');
$posttag = new posttagpublic();
$posttag -> loadtag($content);
$data = array('deviceid' => $posttag -> deviceid, 'tags' => $posttag -> tags, 'productkey' => $posttag -> productkey);
$data = array('deviceid' => $posttag -> deviceid,
'tags' => $posttag -> tags,
'appkey' => $posttag -> appkey);
$this -> redis -> lpush('razor_usertag', serialize($data));
$this -> processor -> process();
}

0 comments on commit 43a81c6

Please sign in to comment.