37 lines
905 B
Python
37 lines
905 B
Python
#coding:utf-8
|
|
'''
|
|
2017-10-26 统计被动引用
|
|
'''
|
|
import MySQLdb
|
|
import re
|
|
|
|
rule = r'/((?:[\w\.-]+/)+)(?:pull|issue)/'
|
|
|
|
|
|
if __name__ == "__main__":
|
|
conn = MySQLdb.connect(host="localhost",user="starlee",passwd="1234",db="duppr",charset='utf8' )
|
|
cursor = conn.cursor()
|
|
|
|
conn2 = MySQLdb.connect(host="localhost",user="starlee",passwd="1234",db="software_relation",charset='utf8' )
|
|
cursor2 = conn2.cursor()
|
|
|
|
cursor.execute("select pr_number,out_ref from pr_home_page_ref where prj_id = 1334")
|
|
result = cursor.fetchall()
|
|
ref_prjs = dict()
|
|
for item in result:
|
|
ref = item[1]
|
|
ref_prj = re.findall(rule,ref)
|
|
for prn in ref_prj:
|
|
op = prn[:-1]
|
|
if op not in ref_prjs.keys():
|
|
ref_prjs[op] = 0
|
|
ref_prjs[op] += 1
|
|
|
|
for key,value in ref_prjs.items():
|
|
cursor2.execute("insert into out_ref(source_prj,target_prj,count) values(%s,%s,%s)",
|
|
("rails/rails",key,value))
|
|
conn2.commit()
|
|
|
|
|
|
|