Commit 21c1ed5d authored by 赵威's avatar 赵威

get data

parent 5935fa28
......@@ -6,6 +6,7 @@ from collections import Counter
import redis
import pymysql
from pyspark import SparkConf
from pyspark.sql import SparkSession
from tool import (get_doris_prod, get_jerry_test, get_tag3_user_log, send_email, write_user_portrait,
......@@ -52,6 +53,84 @@ def merge_results_by_event(lst):
return res
def _make_score(lst, score):
return dict(zip(lst, [score] * len(lst)))
def _get_all_by_project(name):
first_demands = []
second_demands = []
first_solutions = []
second_solutions = []
first_positions = []
second_positions = []
sql = """select name, tag_type from api_tag_3_0 where id in (
select tag_attr.tag_attr_id from api_tag_3_0 as api_tag
left join api_tag_attr_tag as tag_attr on tag_attr.tag_id = api_tag.id
where api_tag.name = '{}')
""".format(name)
zhengxing_conn = pymysql.connect(host="172.16.30.141",
user="work",
password="BJQaT9VzDcuPBqkd",
database="zhengxing",
charset="utf8")
zhengxing_cursor = zhengxing_conn.cursor()
zhengxing_cursor.execute(sql)
sql_tag_results = zhengxing_cursor.fetchall()
# TAG_V3_TYPE
for name, agg_type in sql_tag_results:
if agg_type == 20:
second_demands.append(name)
elif agg_type == 16:
second_solutions.append(name)
elif agg_type == 22:
second_positions.append(name)
elif agg_type == 19:
first_demands.append(name)
elif agg_type == 18:
first_solutions.append(name)
elif agg_type == 21:
first_positions.append(name)
return {
"first_demands": first_demands,
"second_demands": second_demands,
"first_solutions": first_solutions,
"second_solutions": second_solutions,
"first_positions": first_positions,
"second_positions": second_positions,
"projects": [name]
}
def _get_all_by_projects(name_lst):
first_demands = []
second_demands = []
first_solutions = []
second_solutions = []
first_positions = []
second_positions = []
projects = name_lst
for name in projects:
all = _get_all_by_project(name)
first_demands.extend(all.get("first_demands", []))
second_demands.extend(all.get("second_demands", []))
first_solutions.extend(all.get("first_solutions", []))
second_solutions.extend(all.get("second_solutions", []))
first_positions.extend(all.get("first_positions", []))
second_positions.extend(all.get("second_positions", []))
if first_demands or second_demands or first_solutions or second_solutions or first_positions or second_positions or projects:
return {
"first_demands": _make_score(first_demands, 2),
"second_demands": _make_score(second_demands, 2),
"first_solutions": _make_score(first_solutions, 2),
"second_solutions": _make_score(second_solutions, 2),
"first_positions": _make_score(first_positions, 2),
"second_positions": _make_score(second_positions, 2),
"projects": _make_score(projects, 2)
}
return None
def update_tag3_user_portrait_by_event(cl_id):
user_df = get_tag3_user_log(cl_id)
if not user_df.empty:
......@@ -158,7 +237,8 @@ def update_tag3_user_portrait(cl_id):
projects_score[k] = v
if (len(first_demands_score) == 0) and (len(first_solutions_score) == 0) and (len(first_positions_list) == 0):
pass
res = _get_all_by_projects(list(projects_score.keys()))
print(res)
res = {
"first_demands": first_demands_score,
......
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