Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
meta_base_code
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黎涛
meta_base_code
Commits
d787c2fd
Commit
d787c2fd
authored
Sep 16, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
2caa1fe4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
41 deletions
+42
-41
new_user_has_protratit_rate.py
new_user_analysis/new_user_has_protratit_rate.py
+42
-41
No files found.
new_user_analysis/new_user_has_protratit_rate.py
View file @
d787c2fd
...
...
@@ -183,46 +183,47 @@ WHERE spam_pv.device_id IS NULL
for
count
,
res
in
enumerate
(
sql_res
):
# print(count, res)
portratit_res
=
get_user_portrait_tag3_from_redis
(
res
)
print
(
count
,
res
,
portratit_res
)
res_dict
=
{}
if
portratit_res
:
print
(
count
,
res
,
portratit_res
)
# res_dict = {}
#
print
(
"-------------------------------"
)
for
count
,
res
in
enumerate
(
sql_res
):
# print(count, res)
track
=
res
.
track
if
not
track
:
continue
track_list
=
track
.
split
(
","
)
for
one_key_word
in
track_list
:
if
one_key_word
in
res_dict
:
res_dict
[
one_key_word
]
+=
1
else
:
res_dict
[
one_key_word
]
=
1
print
(
res_dict
)
exception_list
=
(
"report_status"
,
"is_open_push"
)
for
action
in
res_dict
:
partition_date
=
yesterday_str
pid
=
hashlib
.
md5
((
partition_date
+
action
)
.
encode
(
"utf8"
))
.
hexdigest
()
action_count
=
res_dict
[
action
]
action_ch
=
name_dict
.
get
(
action
)
if
not
action_ch
:
action_ch
=
action
if
action_ch
in
exception_list
:
continue
instert_sql
=
"""replace into new_user_click_count(
partition_day,pid,action_count,action_ch,action) VALUES('{partition_day}','{pid}',{action_count},'{action_ch}','{action}');"""
.
format
(
partition_date
=
partition_date
,
partition_day
=
yesterday_str
,
pid
=
pid
,
action_count
=
action_count
,
action_ch
=
action_ch
,
action
=
action
)
print
(
instert_sql
)
# cursor.execute("set names 'UTF8'")
db
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'st_user'
,
passwd
=
'aqpuBLYzEV7tML5RPsN1pntUzFy'
,
db
=
'jerry_prod'
)
cursor
=
db
.
cursor
()
res
=
cursor
.
execute
(
instert_sql
)
db
.
commit
()
print
(
res
)
# cursor.executemany()
db
.
close
()
#
for count, res in enumerate(sql_res):
#
# print(count, res)
#
track = res.track
#
if not track:
#
continue
#
track_list = track.split(",")
#
for one_key_word in track_list:
#
if one_key_word in res_dict:
#
res_dict[one_key_word] += 1
#
else:
#
res_dict[one_key_word] = 1
#
print(res_dict)
#
#
exception_list = ("report_status","is_open_push")
#
for action in res_dict:
#
partition_date = yesterday_str
#
pid = hashlib.md5((partition_date + action).encode("utf8")).hexdigest()
#
action_count = res_dict[action]
#
action_ch = name_dict.get(action)
#
if not action_ch:
#
action_ch = action
#
if action_ch in exception_list:
#
continue
#
instert_sql = """replace into new_user_click_count(
#
partition_day,pid,action_count,action_ch,action) VALUES('{partition_day}','{pid}',{action_count},'{action_ch}','{action}');""".format(
#
partition_date=partition_date, partition_day=yesterday_str, pid=pid, action_count=action_count,
#
action_ch=action_ch, action=action
#
)
#
print(instert_sql)
#
# cursor.execute("set names 'UTF8'")
#
db = pymysql.connect(host='172.16.40.158', port=4000, user='st_user', passwd='aqpuBLYzEV7tML5RPsN1pntUzFy',
#
db='jerry_prod')
#
cursor = db.cursor()
#
res = cursor.execute(instert_sql)
#
db.commit()
#
print(res)
#
#
cursor.executemany()
#
db.close()
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