# [1] end stage / [2] start stage
start_pre_build_for_sr_stage(git_tag, bm_start_datetime,
bm_end_datetime, pre_build_project_id)
+
+def sync_sr_update_comment(sr, email, bm_member_sr_info):
+
+ query = "SELECT id FROM sr_status WHERE sr = %s"
+ query_data = (sr,)
+ parent_sr_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ query = "SELECT submit_time FROM sr_status WHERE sr = %s"
+ parent_sr_time = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ if parent_sr_id != INVALID_ID:
+ comment = ''
+ sr_mapping = {}
+ for pname in bm_member_sr_info:
+ for item in bm_member_sr_info[pname]:
+ if item.get('snapshot', 'SYNC') not in sr_mapping:
+ sr_mapping[item.get('snapshot', 'SYNC')] = [item.get('git_tag')]
+ else:
+ if item.get('git_tag') not in sr_mapping[item.get('snapshot', 'SYNC')]:
+ sr_mapping[item.get('snapshot', 'SYNC')].append(item.get('git_tag'))
+ for snapshot in sr_mapping:
+ comment = '%s\n%s:' % (comment, snapshot)
+ for _sr in sr_mapping[snapshot]:
+ query = "SELECT id FROM sr_status WHERE sr = %s"
+ query_data = (_sr,)
+ _sr_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ comment = '%s%s,' % (comment, _sr_id)
+ print comment
+
+ query = "INSERT INTO sr_comment (sr_status_id, user, comment, commented_date) VALUES(%s, %s, %s, %s)"
+ query_data = (parent_sr_id, email.replace('<', '').replace('>', ''), comment, parent_sr_time)
+ buildmonitor_db.do_query(query, query_data)
+
+ query = "UPDATE sr_status SET num_comments = num_comments + 1 WHERE sr = %s"
+ query_data = (sr,)
+ buildmonitor_db.do_query(query, query_data)
+
#==================================================================================
def main():
"""
# member sr for [sr_commit]
sync_sr_submit_for_sr_commit(commit_date, commit_msg,
submit_date, submit_msg,
- submitter, _sr,
- _project, gerrit_newrev,
+ _submitter, _sr,
+ _project, _cid,
gerrit_account_name)
#update_sr_submit_log_completed(git_tag)
+ # Update log for tracing
+ sync_sr_update_comment(bm_sync_git_tag, submitter, bm_member_sr_info)
+
#=======================================================
# [PRE] Build
#=======================================================
print err
bm_disconnect_db()
sys.exit(1)
+