Commit 54640cd8 authored by 高雅喆's avatar 高雅喆

fix bug in test/platform [is not null]

parent 028e45f8
......@@ -27,11 +27,11 @@ class CidRate(object):
sql_cid = "select count(cid) from data_feed_click \
where from_unixtime(time,'%Y-%m-%d')=date_add(curdate(), interval -{0} day) \
and device_type{1} \
and cid_type='{2}'".format(self.ndays,self.platform.replace(' ','') if self.platform[0]=='A' else self.platform,self.cid_type)
and cid_type='{2}'".format(self.ndays,self.platform.replace(' ','') if self.platform[-2]=='e' else self.platform,self.cid_type)
cid_clk_count = con_sql(sql_cid)[0][0]
sql_all = "select count(cid) from data_feed_click \
where from_unixtime(time,'%Y-%m-%d')=date_add(curdate(), interval -{0} day) \
and device_type{1}".format(self.ndays, self.platform.replace(' ','') if self.platform[0]=='A' else self.platform)
and device_type{1}".format(self.ndays, self.platform.replace(' ','') if self.platform[-2]=='e' else self.platform)
all_clk_count = con_sql(sql_all)[0][0]
cid_clk_rate = round(cid_clk_count/all_clk_count,4)
return [platform,cid_clk_count,all_clk_count,cid_clk_rate]
......
......@@ -29,7 +29,7 @@ class ClkCidUidRate(object):
sql_clk = "select count(distinct(device_id)) from data_feed_click \
where from_unixtime(time,'%Y-%m-%d')=date_add(curdate(), interval -{0} day) \
and device_type{1} \
and cid_type{2}".format(self.ndays,self.platform.replace(' ','') if self.platform[0]=='A' else self.platform,self.cid_type)
and cid_type{2}".format(self.ndays,self.platform.replace(' ','') if self.platform[-2]=='e' else self.platform,self.cid_type)
clk_count = con_sql(sql_clk)[0][0]
sql_imp = "select count(distinct(device_id)) from data_feed_exposure \
......
......@@ -28,7 +28,7 @@ class TopFeatures(object):
where from_unixtime(time,'%Y-%m-%d')=date_add(curdate(), interval -{0} day) \
and device_type{1} and cid_type='{2}' \
group by cid \
order by count(cid) desc".format(self.ndays, self.platform.replace(' ','') if self.platform[0]=='A' else self.platform, self.cid_type)
order by count(cid) desc".format(self.ndays, self.platform.replace(' ','') if self.platform[-2]=='e' else self.platform, self.cid_type)
clk_times = tuple2dict(con_sql(sql))
return clk_times
......
......@@ -52,7 +52,7 @@ def get_activate_uid_ctr(platform, ndays=1):
platform = " is not null"
sql_clk = "select count(device_id) from data_feed_click \
where from_unixtime(time,'%Y-%m-%d')=date_add(curdate(), interval -{0} day) \
and device_type{1}".format(ndays, platform.replace(' ','') if platform[0]=='A' else platform)
and device_type{1}".format(ndays, platform.replace(' ','') if platform[-2]=='e' else platform)
clk_count = con_sql(sql_clk)[0][0]
sql_imp = "select count(device_id) from data_feed_exposure \
where from_unixtime(time,'%Y-%m-%d')=date_add(curdate(), interval -{0} day) \
......@@ -60,7 +60,7 @@ def get_activate_uid_ctr(platform, ndays=1):
(select device_id from data_feed_click \
where from_unixtime(time,'%Y-%m-%d')=date_add(curdate(), interval -{1} day) \
and device_type{2}) \
and device_type{3}".format(ndays, ndays, platform.replace(' ','') if platform[0]=='A' else platform, platform)
and device_type{3}".format(ndays, ndays, platform.replace(' ','') if platform[-2]=='e' else platform, platform)
imp_count = con_sql(sql_imp)[0][0]
clk_rate = round(clk_count/imp_count, 4 )
if platform == "='App Store'":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment