From 048ed9a9279ac7b7bbf37580b8806dea4d1037c3 Mon Sep 17 00:00:00 2001 From: Junghyun Kim Date: Tue, 7 Mar 2017 14:08:16 +0900 Subject: [PATCH] Insert package info if not present. Change-Id: I57dedb072e751c0670104f7b0b05e2aa2a50901d Signed-off-by: Junghyun Kim --- job_buildmonitor.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/job_buildmonitor.py b/job_buildmonitor.py index 64326d6..e8866e1 100644 --- a/job_buildmonitor.py +++ b/job_buildmonitor.py @@ -1158,6 +1158,9 @@ def update_build_log(content): def update_unresolvable_broken_packages(project, unresolvable_broken_packages): + if unresolvable_broken_packages is None: + return + # get curr_info_project_id -> get curr_build_project_id for multi profile query = "SELECT id FROM info_project WHERE project_name = %s" query_data = (project,) @@ -1171,14 +1174,29 @@ def update_unresolvable_broken_packages(project, unresolvable_broken_packages): for p in unresolvable_broken_packages[repo][arch]: status = unresolvable_broken_packages[repo][arch][p] + # INSERT package if package is not present. + query = "SELECT id FROM info_package WHERE info_project_id=%s AND package_name=%s "\ + "AND active_flag='Y' ORDER BY id DESC LIMIT 1" + query_data = (curr_info_project_id, p) + curr_info_package_id = buildmonitor_db.get_value_from_query_data(query, query_data) + + if curr_info_package_id == INVALID_ID: + query = "INSERT INTO info_package (info_project_id,package_name,description,"\ + "latest_sr_status_id,active_flag) VALUES (%s, %s, %s, %s, %s)" + query_data = (curr_info_project_id, p, "", 0, 'Y') + buildmonitor_db.do_query(query, query_data) + + query = "SELECT id FROM info_package WHERE info_project_id=%s AND package_name=%s "\ + "AND active_flag='Y' ORDER BY id DESC LIMIT 1" + query_data = (curr_info_project_id, p) + curr_info_package_id = buildmonitor_db.get_value_from_query_data(query, query_data) + query = "INSERT INTO build_package (build_target_id, info_package_id, start_time," \ "end_time, build_status) VALUES ("\ "(SELECT id FROM build_target WHERE build_project_id=%s AND repository=%s "\ "AND arch=%s ORDER BY id DESC LIMIT 1), "\ - "(SELECT id FROM info_package WHERE info_project_id=%s AND package_name=%s "\ - "AND active_flag='Y' ORDER BY id DESC LIMIT 1), "\ - "NOW(), NOW(), %s)" - query_data = (curr_build_project_id, repo, arch, curr_info_project_id, p, status) + "%s, NOW(), NOW(), %s)" + query_data = (curr_build_project_id, repo, arch, curr_info_package_id, status) buildmonitor_db.do_query(query, query_data) #=============================================================================== -- 2.7.4