insert id
This commit is contained in:
parent
b174a3cb5f
commit
bb5fb27987
|
@ -18,9 +18,9 @@ class FileOperator(object):
|
|||
with open(self.path, "r") as file:
|
||||
list = file.read().strip().splitlines()
|
||||
for line in list:
|
||||
ownername, reponame, git_url = line.split(" ")
|
||||
ownername, reponame, git_url, id = line.split(" ")
|
||||
repoInfo = RepoInfo(
|
||||
ownername=ownername, reponame=reponame, git_url=git_url
|
||||
id=id, ownername=ownername, reponame=reponame, git_url=git_url
|
||||
)
|
||||
result.append(repoInfo)
|
||||
return result
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import uuid
|
||||
from typing import List
|
||||
|
||||
import pymysql
|
||||
|
@ -84,20 +85,14 @@ class MySQLOperator(object):
|
|||
params:
|
||||
- repoInfos: a list of RepoInfo objects
|
||||
"""
|
||||
self.cursor.execute(
|
||||
"select max(id) as max_id from repositories"
|
||||
)
|
||||
max_id = self.cursor.fetchone()["max_id"]
|
||||
if max_id is None:
|
||||
max_id = 1
|
||||
for repoInfo in repoInfos:
|
||||
id = repoInfo.id
|
||||
ownername = repoInfo.ownername
|
||||
reponame = repoInfo.reponame
|
||||
self.cursor.execute(
|
||||
"insert ignore into repositories (id, ownername, reponame, handled) values (%s, %s, %s, %s)",
|
||||
(max_id, ownername, reponame, 0),
|
||||
(id, ownername, reponame, 0),
|
||||
)
|
||||
max_id = max_id + 1
|
||||
self.connection.commit()
|
||||
|
||||
def update_handled_repository(self, repoInfo: RepoInfo):
|
||||
|
@ -109,19 +104,10 @@ class MySQLOperator(object):
|
|||
ownername = repoInfo.ownername
|
||||
reponame = repoInfo.reponame
|
||||
self.cursor.execute(
|
||||
"select handled from `{repo_id}{separator}steps`".format(
|
||||
repo_id=repoInfo.id,
|
||||
separator=GlobalConstants.SEPARATOR,
|
||||
"update repositories set handled = 1 where ownername=%s and reponame=%s",
|
||||
(ownername, reponame),
|
||||
)
|
||||
)
|
||||
handled = self.cursor.fetchall()
|
||||
handled = [step["handled"] for step in handled]
|
||||
if 0 not in handled:
|
||||
self.cursor.execute(
|
||||
"update repositories set handled = 1 where ownername=%s and reponame=%s",
|
||||
(ownername, reponame),
|
||||
)
|
||||
self.connection.commit()
|
||||
self.connection.commit()
|
||||
|
||||
def init_steps_table(self, repoInfo: RepoInfo):
|
||||
"""
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
apache ant git@github.com:apache/ant.git
|
||||
apache dubbo git@github.com:apache/dubbo.git
|
||||
apache kafka git@github.com:apache/kafka.git
|
||||
apache maven git@github.com:apache/maven.git
|
||||
apache rocketmq git@github.com:apache/rocketmq.git
|
||||
apache ant git@github.com:apache/ant.git 11
|
||||
apache dubbo git@github.com:apache/dubbo.git 12
|
||||
apache kafka git@github.com:apache/kafka.git 13
|
||||
apache maven git@github.com:apache/maven.git 14
|
||||
apache rocketmq git@github.com:apache/rocketmq.git 15
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
apache ant git@github.com:apache/ant.git
|
||||
apache dubbo git@github.com:apache/dubbo.git
|
||||
apache kafka git@github.com:apache/kafka.git
|
||||
apache maven git@github.com:apache/maven.git
|
||||
apache rocketmq git@github.com:apache/rocketmq.git
|
||||
apache ant git@github.com:apache/ant.git 11
|
||||
apache dubbo git@github.com:apache/dubbo.git 12
|
||||
apache kafka git@github.com:apache/kafka.git 13
|
||||
apache maven git@github.com:apache/maven.git 14
|
||||
apache rocketmq git@github.com:apache/rocketmq.git 15
|
||||
|
|
Loading…
Reference in New Issue