Commit 971bb156 authored by 赵威's avatar 赵威

get user log

parent 3b624793
from tool import get_tag3_user_log
def update_tag3_user_portrait(cl_id):
user_df = get_tag3_user_log(cl_id)
if not user_df.empty:
pass
if __name__ == "__main__":
cl_id = "866017030837899"
a = get_tag3_user_log(cl_id)
......
......@@ -365,20 +365,38 @@ def get_jerry_test_cursor():
return db.cursor()
def compute_tag3_score(x):
if x.score_type == "henqiang":
return compute_henqiang(x.days_diff_now, exponential=1)
elif x.score_type == "jiaoqiang":
return compute_jiaoqiang(x.days_diff_now, exponential=1)
elif x.score_type == "ai_scan":
return compute_ai_scan(x.days_diff_now, exponential=1)
elif x.score_type == "ruoyixiang":
return compute_ruoyixiang(x.days_diff_now, exponential=1)
else:
return compute_validate(x.days_diff_now, exponential=1)
def get_tag3_user_log(cl_id):
columns = [
"log_time", "cl_id", "tag_referrer", "score_type", "action", "event", "event_cn", "first_solutions",
"second_solutions", "first_demands", "second_demands", "first_positions", "second_positions",
"projects", "card_type"
"log_time", "score_type", "event_cn", "first_solutions", "second_solutions", "first_demands",
"second_demands", "first_positions", "second_positions", "projects"
]
sql = """select log_time, cl_id, tag_referrer, score_type, action, event, event_cn, first_solutions,
second_solutions, first_demands, second_demands, first_positions, second_positions,
projects, card_type from kafka_tag3_log where cl_id = '{}'""".format(cl_id)
sql = """select log_time, score_type, event_cn, first_solutions, second_solutions, first_demands,
second_demands, first_positions, second_positions, projects
from kafka_tag3_log where cl_id = '{}'""".format(cl_id)
cursor = get_jerry_test_cursor()
cursor.execute(sql)
data = list(cursor.fetchall())
user_df = pd.DataFrame(data)
user_df.columns = columns
if data:
user_df = pd.DataFrame(data)
user_df.columns = columns
else:
return pd.DataFrame(columns=columns)
user_df["days_diff_now"] = round((int(time.time()) - user_df["log_time"].astype(float)) / (24 * 60 * 60))
user_df["tag_score"] = user_df.apply(lambda x: compute_tag3_score(x), axis=1)
return user_df
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