Commit 9ec57af6 authored by 高雅喆's avatar 高雅喆

rename table date_feed_

parent 424954a0
...@@ -22,7 +22,7 @@ class GrayStat(object): ...@@ -22,7 +22,7 @@ class GrayStat(object):
self.ndays = ndays self.ndays = ndays
def get_uid_count(self): def get_uid_count(self):
sql = "select count(distinct(device_id)) from data_feed_click2 \ sql = "select count(distinct(device_id)) from data_feed_click \
where stat_date='{0}' \ where stat_date='{0}' \
and cid_type='{3}' \ and cid_type='{3}' \
and device_id regexp '[{1}]$' \ and device_id regexp '[{1}]$' \
...@@ -32,7 +32,7 @@ class GrayStat(object): ...@@ -32,7 +32,7 @@ class GrayStat(object):
return uid_count return uid_count
def get_uid_clk_times(self): def get_uid_clk_times(self):
sql = "select count(device_id) from data_feed_click2 \ sql = "select count(device_id) from data_feed_click \
where stat_date='{0}' \ where stat_date='{0}' \
and cid_type='{3}' \ and cid_type='{3}' \
and device_id regexp '[{1}]$' \ and device_id regexp '[{1}]$' \
...@@ -42,12 +42,12 @@ class GrayStat(object): ...@@ -42,12 +42,12 @@ class GrayStat(object):
return uid_clk_times return uid_clk_times
def get_uid_imp_times(self): def get_uid_imp_times(self):
sql = "select count(device_id) from data_feed_exposure2 \ sql = "select count(device_id) from data_feed_exposure \
where stat_date='{0}' \ where stat_date='{0}' \
and cid_type='{4}' \ and cid_type='{4}' \
and device_id regexp '[{1}]$' \ and device_id regexp '[{1}]$' \
and device_type{2} \ and device_type{2} \
and device_id in (select device_id from data_feed_click2 \ and device_id in (select device_id from data_feed_click \
where stat_date='{0}' \ where stat_date='{0}' \
and cid_type='{4}' \ and cid_type='{4}' \
and device_id regexp '[{1}]$' \ and device_id regexp '[{1}]$' \
......
...@@ -22,12 +22,12 @@ class CidRate(object): ...@@ -22,12 +22,12 @@ class CidRate(object):
platform : "所有";"苹果","安卓" #方便显示 platform : "所有";"苹果","安卓" #方便显示
rtype : list rtype : list
""" """
sql_cid = "select count(cid) from data_feed_click2 \ sql_cid = "select count(cid) from data_feed_click \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_type{1} \ and device_type{1} \
and cid_type='{2}'".format(get_yesterday_date(),self.platform.replace(' ','') if self.platform[-2]=='e' else self.platform,self.cid_type) and cid_type='{2}'".format(get_yesterday_date(),self.platform.replace(' ','') if self.platform[-2]=='e' else self.platform,self.cid_type)
cid_clk_count = con_sql(sql_cid)[0][0] cid_clk_count = con_sql(sql_cid)[0][0]
sql_all = "select count(cid) from data_feed_click2 \ sql_all = "select count(cid) from data_feed_click \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_type{1}".format(get_yesterday_date(), self.platform.replace(' ','') if self.platform[-2]=='e' else self.platform) and device_type{1}".format(get_yesterday_date(), self.platform.replace(' ','') if self.platform[-2]=='e' else self.platform)
all_clk_count = con_sql(sql_all)[0][0] all_clk_count = con_sql(sql_all)[0][0]
...@@ -40,11 +40,11 @@ class CidRate(object): ...@@ -40,11 +40,11 @@ class CidRate(object):
platform : "所有";"苹果","安卓" #方便显示 platform : "所有";"苹果","安卓" #方便显示
rtype : list rtype : list
""" """
sql_cid = "select count(cid) from data_feed_exposure2 \ sql_cid = "select count(cid) from data_feed_exposure \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_type{1} and cid_type='{2}'".format(get_yesterday_date(),self.platform,self.cid_type) and device_type{1} and cid_type='{2}'".format(get_yesterday_date(),self.platform,self.cid_type)
cid_imp_count = con_sql(sql_cid)[0][0] cid_imp_count = con_sql(sql_cid)[0][0]
sql_all = "select count(cid) from data_feed_exposure2 \ sql_all = "select count(cid) from data_feed_exposure \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_type{1}".format(get_yesterday_date(), self.platform) and device_type{1}".format(get_yesterday_date(), self.platform)
all_imp_count = con_sql(sql_all)[0][0] all_imp_count = con_sql(sql_all)[0][0]
......
...@@ -24,13 +24,13 @@ class ClkCidUidRate(object): ...@@ -24,13 +24,13 @@ class ClkCidUidRate(object):
platform : "所有";"苹果","安卓" #方便显示 platform : "所有";"苹果","安卓" #方便显示
rtype : list rtype : list
""" """
sql_clk = "select count(distinct(device_id)) from data_feed_click2 \ sql_clk = "select count(distinct(device_id)) from data_feed_click \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_type{1} \ and device_type{1} \
and cid_type{2}".format(get_yesterday_date(),self.platform.replace(' ','') if self.platform[-2]=='e' else self.platform,self.cid_type) and cid_type{2}".format(get_yesterday_date(),self.platform.replace(' ','') if self.platform[-2]=='e' else self.platform,self.cid_type)
clk_count = con_sql(sql_clk)[0][0] clk_count = con_sql(sql_clk)[0][0]
sql_imp = "select count(distinct(device_id)) from data_feed_exposure2 \ sql_imp = "select count(distinct(device_id)) from data_feed_exposure \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_type{1} \ and device_type{1} \
and cid_type{2}".format(get_yesterday_date(),self.platform,self.cid_type) and cid_type{2}".format(get_yesterday_date(),self.platform,self.cid_type)
......
...@@ -16,14 +16,14 @@ def get_activate_uid_ctr(platform): ...@@ -16,14 +16,14 @@ def get_activate_uid_ctr(platform):
platform = "!='App Store'" platform = "!='App Store'"
else: else:
platform = " is not null" platform = " is not null"
sql_clk = "select count(device_id) from data_feed_click2 \ sql_clk = "select count(device_id) from data_feed_click \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_type{1}".format(get_yesterday_date(), platform.replace(' ','') if platform[-2]=='e' else platform) and device_type{1}".format(get_yesterday_date(), platform.replace(' ','') if platform[-2]=='e' else platform)
clk_count = con_sql(sql_clk)[0][0] clk_count = con_sql(sql_clk)[0][0]
sql_imp = "select count(device_id) from data_feed_exposure2 \ sql_imp = "select count(device_id) from data_feed_exposure \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_id in \ and device_id in \
(select device_id from data_feed_click2 \ (select device_id from data_feed_click \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_type{1}) \ and device_type{1}) \
and device_type{2}".format(get_yesterday_date(), platform.replace(' ','') if platform[-2]=='e' else platform, platform) and device_type{2}".format(get_yesterday_date(), platform.replace(' ','') if platform[-2]=='e' else platform, platform)
...@@ -47,13 +47,13 @@ def get_activate_uid_imp_times(city): ...@@ -47,13 +47,13 @@ def get_activate_uid_imp_times(city):
city = "='beijing'" city = "='beijing'"
else: else:
city = " is not null" city = " is not null"
sql_uid = "select count(distinct(device_id)) from data_feed_click2 \ sql_uid = "select count(distinct(device_id)) from data_feed_click \
where stat_date = '{0}' \ where stat_date = '{0}' \
and city_id{1}".format(get_yesterday_date(),city) and city_id{1}".format(get_yesterday_date(),city)
sql_uid_count = con_sql(sql_uid)[0][0] sql_uid_count = con_sql(sql_uid)[0][0]
sql_imp = "select count(device_id) from data_feed_exposure2 \ sql_imp = "select count(device_id) from data_feed_exposure \
where device_id in \ where device_id in \
(select device_id from data_feed_click2 \ (select device_id from data_feed_click \
where stat_date = '{0}' \ where stat_date = '{0}' \
and city_id{1}) \ and city_id{1}) \
and stat_date = '{0}' \ and stat_date = '{0}' \
...@@ -87,7 +87,7 @@ def get_click_times_to_count_uid(): ...@@ -87,7 +87,7 @@ def get_click_times_to_count_uid():
""" """
sql = "select times,count(device_id) \ sql = "select times,count(device_id) \
from (select device_id,count(cid_type) as times \ from (select device_id,count(cid_type) as times \
from data_feed_click2 \ from data_feed_click \
where from_unixtime(time,'%Y-%m-%d')=date_add(curdate(), interval -1 day) \ where from_unixtime(time,'%Y-%m-%d')=date_add(curdate(), interval -1 day) \
group by device_id) as t \ group by device_id) as t \
group by times order by times" group by times order by times"
......
...@@ -29,100 +29,100 @@ def get_click_zero_uid_count(platform): ...@@ -29,100 +29,100 @@ def get_click_zero_uid_count(platform):
platform = " is not null" platform = " is not null"
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test') db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test')
cursor = db.cursor() cursor = db.cursor()
sql = "select '0-7' as label,count(distinct(device_id)) from data_feed_exposure2 \ sql = "select '0-7' as label,count(distinct(device_id)) from data_feed_exposure \
where device_type{0} \ where device_type{0} \
and stat_date = '{7}' \ and stat_date = '{7}' \
and device_id not in \ and device_id not in \
(select distinct(device_id) from data_feed_click2 \ (select distinct(device_id) from data_feed_click \
where stat_date = '{7}' \ where stat_date = '{7}' \
and device_type{1}) \ and device_type{1}) \
and device_id in \ and device_id in \
(select distinct(device_id) \ (select distinct(device_id) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id not in \ where device_id not in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {2})) \ where stat_date < {2})) \
union all \ union all \
select '7-14' as label,count(distinct(device_id)) from data_feed_exposure2 \ select '7-14' as label,count(distinct(device_id)) from data_feed_exposure \
where device_type{0} \ where device_type{0} \
and stat_date = '{7}' \ and stat_date = '{7}' \
and device_id not in \ and device_id not in \
(select distinct(device_id) from data_feed_click2 \ (select distinct(device_id) from data_feed_click \
where stat_date = '{7}' \ where stat_date = '{7}' \
and device_type{1}) \ and device_type{1}) \
and device_id in \ and device_id in \
(select distinct(device_id) \ (select distinct(device_id) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id not in \ where device_id not in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {3}) \ where stat_date < {3}) \
and device_id in \ and device_id in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {2})) \ where stat_date < {2})) \
union all \ union all \
select '14-30' as label,count(distinct(device_id)) from data_feed_exposure2 \ select '14-30' as label,count(distinct(device_id)) from data_feed_exposure \
where device_type{0} \ where device_type{0} \
and stat_date = '{7}' \ and stat_date = '{7}' \
and device_id not in \ and device_id not in \
(select distinct(device_id) from data_feed_click2 \ (select distinct(device_id) from data_feed_click \
where stat_date = '{7}' \ where stat_date = '{7}' \
and device_type{1}) \ and device_type{1}) \
and device_id in \ and device_id in \
(select distinct(device_id) \ (select distinct(device_id) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id not in \ where device_id not in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {4}) \ where stat_date < {4}) \
and device_id in \ and device_id in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {3})) \ where stat_date < {3})) \
union all \ union all \
select '30-60' as label,count(distinct(device_id)) from data_feed_exposure2 \ select '30-60' as label,count(distinct(device_id)) from data_feed_exposure \
where device_type{0} \ where device_type{0} \
and stat_date = '{7}' \ and stat_date = '{7}' \
and device_id not in \ and device_id not in \
(select distinct(device_id) from data_feed_click2 \ (select distinct(device_id) from data_feed_click \
where stat_date = '{7}' \ where stat_date = '{7}' \
and device_type{1}) \ and device_type{1}) \
and device_id in \ and device_id in \
(select distinct(device_id) \ (select distinct(device_id) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id not in \ where device_id not in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {5}) \ where stat_date < {5}) \
and device_id in \ and device_id in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {4})) \ where stat_date < {4})) \
union all \ union all \
select '60-90' as label,count(distinct(device_id)) from data_feed_exposure2 \ select '60-90' as label,count(distinct(device_id)) from data_feed_exposure \
where device_type{0} \ where device_type{0} \
and stat_date = '{7}' \ and stat_date = '{7}' \
and device_id not in \ and device_id not in \
(select distinct(device_id) from data_feed_click2 \ (select distinct(device_id) from data_feed_click \
where stat_date = '{7}' \ where stat_date = '{7}' \
and device_type{1}) \ and device_type{1}) \
and device_id in \ and device_id in \
(select distinct(device_id) \ (select distinct(device_id) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id not in \ where device_id not in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {6}) \ where stat_date < {6}) \
and device_id in \ and device_id in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {5})) \ where stat_date < {5})) \
union all \ union all \
select '90+' as label,count(distinct(device_id)) from data_feed_exposure2 \ select '90+' as label,count(distinct(device_id)) from data_feed_exposure \
where device_type{0} \ where device_type{0} \
and stat_date = '{7}' \ and stat_date = '{7}' \
and device_id not in \ and device_id not in \
(select distinct(device_id) from data_feed_click2 \ (select distinct(device_id) from data_feed_click \
where stat_date = '{7}' \ where stat_date = '{7}' \
and device_type{1}) \ and device_type{1}) \
and device_id in \ and device_id in \
(select distinct(device_id) \ (select distinct(device_id) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id in \ where device_id in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {6}))".format(platform,platform.replace(' ','') if platform[-2]=='e' else platform,my_date1,my_date2,my_date3,my_date4,my_date5,get_yesterday_date()) where stat_date < {6}))".format(platform,platform.replace(' ','') if platform[-2]=='e' else platform,my_date1,my_date2,my_date3,my_date4,my_date5,get_yesterday_date())
cursor.execute(sql) cursor.execute(sql)
result = cursor.fetchall() result = cursor.fetchall()
......
...@@ -21,51 +21,51 @@ def get_register_uid_count(): ...@@ -21,51 +21,51 @@ def get_register_uid_count():
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test') db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test')
cursor = db.cursor() cursor = db.cursor()
sql = "select '0-7' as label,count(distinct(device_id)) \ sql = "select '0-7' as label,count(distinct(device_id)) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id not in \ where device_id not in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {0}) \ where stat_date < {0}) \
union all \ union all \
select '7-14' as label,count(distinct(device_id)) \ select '7-14' as label,count(distinct(device_id)) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id not in \ where device_id not in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {1}) \ where stat_date < {1}) \
and device_id in \ and device_id in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {0}) \ where stat_date < {0}) \
union all \ union all \
select '14-30' as label,count(distinct(device_id)) \ select '14-30' as label,count(distinct(device_id)) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id not in \ where device_id not in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {2}) \ where stat_date < {2}) \
and device_id in \ and device_id in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {1}) \ where stat_date < {1}) \
union all \ union all \
select '30-60' as label,count(distinct(device_id)) \ select '30-60' as label,count(distinct(device_id)) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id not in \ where device_id not in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {3}) \ where stat_date < {3}) \
and device_id in \ and device_id in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {2}) \ where stat_date < {2}) \
union all \ union all \
select '60-90' as label,count(distinct(device_id)) \ select '60-90' as label,count(distinct(device_id)) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id not in \ where device_id not in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {4}) \ where stat_date < {4}) \
and device_id in \ and device_id in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {3}) \ where stat_date < {3}) \
union all \ union all \
select '90+' as label,count(distinct(device_id)) \ select '90+' as label,count(distinct(device_id)) \
from data_feed_exposure2 \ from data_feed_exposure \
where device_id in \ where device_id in \
(select distinct(device_id) from data_feed_exposure2 \ (select distinct(device_id) from data_feed_exposure \
where stat_date < {4})".format(my_date1,my_date2,my_date3,my_date4,my_date5) where stat_date < {4})".format(my_date1,my_date2,my_date3,my_date4,my_date5)
cursor.execute(sql) cursor.execute(sql)
result = cursor.fetchall() result = cursor.fetchall()
......
...@@ -22,7 +22,7 @@ class TopFeatures(object): ...@@ -22,7 +22,7 @@ class TopFeatures(object):
def get_click_times(self): def get_click_times(self):
# rtype : dict # rtype : dict
sql = "select cid,count(cid) from data_feed_click2 \ sql = "select cid,count(cid) from data_feed_click \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_type{1} and cid_type='{2}' \ and device_type{1} and cid_type='{2}' \
group by cid \ group by cid \
...@@ -33,7 +33,7 @@ class TopFeatures(object): ...@@ -33,7 +33,7 @@ class TopFeatures(object):
def get_impression_times(self): def get_impression_times(self):
# rtype : dict # rtype : dict
sql = "select cid,count(cid) from data_feed_exposure2 \ sql = "select cid,count(cid) from data_feed_exposure \
where stat_date = '{0}' \ where stat_date = '{0}' \
and device_type{1} and cid_type='{2}' \ and device_type{1} and cid_type='{2}' \
group by cid order by count(cid) desc".format(get_yesterday_date(), self.platform, self.cid_type) group by cid order by count(cid) desc".format(get_yesterday_date(), self.platform, self.cid_type)
......
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