Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
20a228e2
Commit
20a228e2
authored
Oct 08, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change
parent
f0771557
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
100 deletions
+109
-100
meigou.py
local/meigou.py
+109
-100
No files found.
local/meigou.py
View file @
20a228e2
...
@@ -8,111 +8,111 @@ import time
...
@@ -8,111 +8,111 @@ import time
from
pyspark
import
StorageLevel
from
pyspark
import
StorageLevel
def
click
(
x
):
def
all_
click
(
x
):
total
=
[]
total
=
[]
sum
=
0
date
=
(
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
x
))
.
strftime
(
"
%
Y
%
m
%
d"
)
total
.
append
(
date
)
print
(
"美购首页美购列表卡片点击"
)
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
"where partition_date='{}' "
"and action = 'goto_welfare_detail' and params['from'] = 'welfare_home_list_item'"
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()[
0
]
total
.
append
(
tmp
)
sum
=
sum
+
tmp
print
(
"美券相关的美购列表页美购卡片点击"
)
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
"where partition_date='{}' "
"and action = 'goto_welfare_detail' and params['from'] = 'coupon_welfare_list'"
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()[
0
]
total
.
append
(
tmp
)
sum
=
sum
+
tmp
print
(
"新美购首页-固定ICON美购卡片点击"
)
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
"where partition_date='{}' "
"and action = 'goto_welfare_detail' and params['from'] = 'welfare_list'"
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()[
0
]
total
.
append
(
tmp
)
sum
=
sum
+
tmp
print
(
"首页-品类模块点击跳转到品类聚合美购卡片点击"
)
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
"where partition_date='{}' "
"and action = 'goto_welfare_detail' and params['from'] = 'category'"
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()[
0
]
total
.
append
(
tmp
)
sum
=
sum
+
tmp
print
(
"serach"
)
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
"where partition_date='{}' "
"and action = 'search_result_welfare_click_item'"
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()[
0
]
total
.
append
(
tmp
)
sum
=
sum
+
tmp
total
.
append
(
sum
)
print
(
total
)
return
total
def
cpc_click
(
x
):
cpc
=
[]
cpc
=
[]
date
=
(
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
x
))
.
strftime
(
"
%
Y
%
m
%
d"
)
date
=
(
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
x
))
.
strftime
(
"
%
Y
%
m
%
d"
)
cpc
.
append
(
date
)
sum
=
0
print
(
"美购首页美购列表卡片点击"
)
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
"where partition_date='{}' "
"and action = 'goto_welfare_detail' and params['from'] = 'welfare_home_list_item' "
"and params['is_cpc'] = '1'"
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()[
0
]
cpc
.
append
(
tmp
)
sum
=
sum
+
tmp
print
(
"美券相关的美购列表页美购卡片点击"
)
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
"where partition_date='{}' "
"and action = 'goto_welfare_detail' and params['from'] = 'coupon_welfare_list' "
"and params['is_cpc'] = '1'"
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()[
0
]
cpc
.
append
(
tmp
)
sum
=
sum
+
tmp
print
(
"新美购首页-固定ICON美购卡片点击"
)
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
"where partition_date='{}' "
"and action = 'goto_welfare_detail' and params['from'] = 'welfare_list' "
"and params['is_cpc'] = '1'"
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()[
0
]
cpc
.
append
(
tmp
)
sum
=
sum
+
tmp
print
(
"首页-品类模块点击跳转到品类聚合美购卡片点击"
)
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
"where partition_date='{}' "
"and action = 'goto_welfare_detail' and params['from'] = 'category' "
"and params['is_cpc'] = '1'"
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()[
0
]
cpc
.
append
(
tmp
)
sum
=
sum
+
tmp
print
(
"serach"
)
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
tmp
=
spark
.
sql
(
"select count(*) from online.bl_hdfs_maidian_updates "
"where partition_date='{}' "
"where partition_date='{}' "
"and action = 'search_result_welfare_click_item' "
"and action = 'search_result_welfare_click_item' "
"and app['version'] in ('7.15.0','7.14.0')"
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()
"and params['is_cpc'] = '1'"
print
(
tmp
)
.
format
(
date
))
.
rdd
.
map
(
lambda
x
:
x
[
0
])
.
collect
()[
0
]
cpc
.
append
(
tmp
)
sum
=
sum
+
tmp
# spark.sql(
# s
cpc
.
append
(
sum
)
# """
print
(
cpc
)
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "search_result_welfare_click_item" and app["version"] in ('7.15.0','7.14.0')
return
cpc
# |and params["is_cpc"] = "1"
# """.stripMargin).show(6)
#
# println("首页点全部icon进入的列表-美购卡片点击")
# spark.sql(
# s
# """
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "goto_welfare_detail" and app["version"] in ('7.15.0','7.14.0')
# |and params["from"] = "welfare_list" and params["cpc_referer"] = "6"
# """.stripMargin).show()
#
# spark.sql(
# s
# """
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "goto_welfare_detail" and app["version"] in ('7.15.0','7.14.0')
# |and params["from"] = "welfare_list" and params["cpc_referer"] = "6"
# |and params["is_cpc"] = "1"
# """.stripMargin).show()
#
# println("首页点击icon进入的列表-美购卡片点击")
# spark.sql(
# s
# """
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "goto_welfare_detail" and app["version"] in ('7.15.0','7.14.0')
# |and params["from"] = "category" and params["cpc_referer"] = "19"
# """.stripMargin).show()
# spark.sql(
# s
# """
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "goto_welfare_detail" and app["version"] in ('7.15.0','7.14.0')
# |and params["from"] = "category" and params["cpc_referer"] = "19"
# |and params["is_cpc"] = "1"
# """.stripMargin).show()
#
# println("美购首页全部点击")
# spark.sql(
# s
# """
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "goto_welfare_detail" and app["version"] in ('7.15.0','7.14.0')
# |and params["from"] = "welfare_list" and params["cpc_referer"] = "21"
# """.stripMargin).show()
# spark.sql(
# s
# """
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "goto_welfare_detail" and app["version"] in ('7.15.0','7.14.0')
# |and params["from"] = "welfare_list" and params["cpc_referer"] = "21"
# |and params["is_cpc"] = "1"
# """.stripMargin).show()
#
# println("美购首页icon美购点击")
# spark.sql(
# s
# """
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "goto_welfare_detail" and app["version"] in ('7.15.0','7.14.0')
# |and params["from"] = "welfare_list" and params["cpc_referer"] = "18"
# """.stripMargin).show()
# spark.sql(
# s
# """
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "goto_welfare_detail" and app["version"] in ('7.15.0','7.14.0')
# |and params["from"] = "welfare_list" and params["cpc_referer"] = "18"
# |and params["is_cpc"] = "1"
# """.stripMargin).show()
#
# println("美购首页相关推荐")
# spark.sql(
# s
# """
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "goto_welfare_detail" and app["version"] in ('7.15.0','7.14.0')
# |and params["from"] = "welfare_home_list_item"
# """.stripMargin).show()
# spark.sql(
# s
# """
# |select count(*) from online.bl_hdfs_maidian_updates where partition_date='$date'
# |and action = "goto_welfare_detail" and app["version"] in ('7.15.0','7.14.0')
# |and params["from"] = "welfare_home_list_item"
# |and params["is_cpc"] = "1"
# """.stripMargin).show()
# return sum
...
@@ -126,7 +126,16 @@ if __name__ == '__main__':
...
@@ -126,7 +126,16 @@ if __name__ == '__main__':
.
set
(
"spark.driver.maxResultSize"
,
"8g"
)
.
set
(
"spark.sql.avro.compression.codec"
,
"snappy"
)
.
set
(
"spark.driver.maxResultSize"
,
"8g"
)
.
set
(
"spark.sql.avro.compression.codec"
,
"snappy"
)
spark
=
SparkSession
.
builder
.
config
(
conf
=
sparkConf
)
.
enableHiveSupport
()
.
getOrCreate
()
spark
=
SparkSession
.
builder
.
config
(
conf
=
sparkConf
)
.
enableHiveSupport
()
.
getOrCreate
()
click
(
1
)
clicks
=
[]
cpcs
=
[]
for
i
in
range
(
1
,
26
):
clicks
.
extend
(
all_click
(
i
))
cpcs
.
extend
(
cpc_click
(
i
))
print
(
"clicks"
)
print
(
clicks
)
print
(
"cpcs"
)
print
(
cpcs
)
spark
.
stop
()
spark
.
stop
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment