Commit f0ab152d authored by 赵威's avatar 赵威

try write data

parent 1e2860ff
...@@ -4,17 +4,16 @@ import json ...@@ -4,17 +4,16 @@ import json
import operator import operator
from collections import Counter from collections import Counter
import pymysql
import pytz import pytz
import redis import redis
import pymysql
from es_tool import es_insert_device_info
from pyspark import SparkConf from pyspark import SparkConf
from pyspark.sql import SparkSession from pyspark.sql import SparkSession
from tool import (get_doris_prod, get_jerry_test, get_redis_client,
get_tag3_user_log, get_user_portrait_tag3_from_redis, from es_tool import es_insert_device_info
get_user_portrait_tag3_with_score, send_email, write_user_portrait, from tool import (get_doris_prod, get_jerry_test, get_redis_client, get_tag3_user_log, get_user_portrait_tag3_from_redis,
write_user_portrait_by_event, write_user_portrait_doris) get_user_portrait_tag3_with_score, send_email, write_user_portrait, write_user_portrait_by_event,
write_user_portrait_doris)
# [{'激光': 1.949194898204873}, {'手术': 1.949194898204873}, {'手术': 1.949194898204873}, {'手术': 1.949194898204873, '植发际线': 7.1}] # [{'激光': 1.949194898204873}, {'手术': 1.949194898204873}, {'手术': 1.949194898204873}, {'手术': 1.949194898204873, '植发际线': 7.1}]
...@@ -268,15 +267,13 @@ def update_tag3_user_portrait(cl_id): ...@@ -268,15 +267,13 @@ def update_tag3_user_portrait(cl_id):
(len(first_solutions_score.keys()) > 0) or (len(second_solutions_score.keys()) > 0) or \ (len(first_solutions_score.keys()) > 0) or (len(second_solutions_score.keys()) > 0) or \
(len(first_positions_score.keys()) > 0) or (len(second_positions_score.keys()) > 0) or \ (len(first_positions_score.keys()) > 0) or (len(second_positions_score.keys()) > 0) or \
(len(projects_score.keys()) > 0): (len(projects_score.keys()) > 0):
pass redis_client.set(key, json.dumps(res))
# TODO redis_client.expire(key, 60 * 60 * 24 * 180)
# redis_client.set(key, json.dumps(res))
# redis_client.expire(key, 60 * 60 * 24 * 180)
# write_user_portrait(cl_id, ",".join(first_solutions_score.keys()), ",".join(second_solutions_score.keys()), write_user_portrait(cl_id, ",".join(first_solutions_score.keys()), ",".join(second_solutions_score.keys()),
# ",".join(first_demands_score.keys()), ",".join(second_demands_score.keys()), ",".join(first_demands_score.keys()), ",".join(second_demands_score.keys()),
# ",".join(first_positions_score.keys()), ",".join(second_positions_score.keys()), ",".join(first_positions_score.keys()), ",".join(second_positions_score.keys()),
# ",".join(projects_score.keys())) ",".join(projects_score.keys()))
body = {} body = {}
for (k, v) in res.items(): for (k, v) in res.items():
...@@ -285,9 +282,7 @@ def update_tag3_user_portrait(cl_id): ...@@ -285,9 +282,7 @@ def update_tag3_user_portrait(cl_id):
body["device_id"] = cl_id body["device_id"] = cl_id
body["last_modified"] = datetime.datetime.strftime(datetime.datetime.now(pytz.timezone("Asia/Shanghai")), body["last_modified"] = datetime.datetime.strftime(datetime.datetime.now(pytz.timezone("Asia/Shanghai")),
"%Y-%m-%dT%H:%M:%S.%f")[:-7] + "Z" "%Y-%m-%dT%H:%M:%S.%f")[:-7] + "Z"
es_insert_device_info(cl_id, body)
print(body)
# es_insert_device_info(cl_id, body)
# # write_user_portrait_doris(cl_id, ",".join(first_solutions_score.keys()), ",".join(second_solutions_score.keys()), # # write_user_portrait_doris(cl_id, ",".join(first_solutions_score.keys()), ",".join(second_solutions_score.keys()),
# # ",".join(first_demands_score.keys()), ",".join(second_demands_score.keys()), # # ",".join(first_demands_score.keys()), ",".join(second_demands_score.keys()),
......
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