forked from importers/git-importer
execute user import
This commit is contained in:
parent
5ed847de8b
commit
10cd7e4e38
@ -159,7 +159,6 @@ class DB:
|
||||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
userid VARCHAR(255) NOT NULL,
|
||||
login VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
realname VARCHAR(255) NOT NULL
|
||||
)
|
||||
|
@ -10,6 +10,7 @@ from lib.obs import OBS
|
||||
from lib.obs_revision import OBSRevision
|
||||
from lib.proxy_sha256 import ProxySHA256, md5, sha256
|
||||
from lib.request import Request
|
||||
from lib.users import Users
|
||||
|
||||
|
||||
def _files_hash(hash_alg, dirpath):
|
||||
@ -173,6 +174,10 @@ class Importer:
|
||||
else:
|
||||
rev.set_broken(db)
|
||||
|
||||
fake_accounts = ["unknown","buildservice-autocommit", "autobuild", "_service"]
|
||||
if Users.user_lookup(db, rev.userid) is None and rev.userid not in fake_accounts:
|
||||
self.obs.users(rev.userid).import_into_db(db)
|
||||
|
||||
for number in DBRevision.requests_to_fetch(db, project, self.package):
|
||||
self.obs.request(number).import_into_db(db)
|
||||
|
||||
|
14
lib/users.py
14
lib/users.py
@ -1,14 +1,13 @@
|
||||
class Users:
|
||||
def parse(self, xml, userid):
|
||||
self.userid = userid
|
||||
self.login = xml.get("login")
|
||||
self.realname = xml.find("login").get("realname")
|
||||
self.email = xml.find("login").get("email")
|
||||
self.realname = xml.find("realname").text
|
||||
self.email = xml.find("email").text
|
||||
|
||||
return self
|
||||
|
||||
def __str__(self):
|
||||
return f"User {self.userid} {self.login}: {self.realname} {self.email}"
|
||||
return f"User {self.userid}: {self.realname} {self.email}"
|
||||
|
||||
def __repr__(self):
|
||||
return f"[{self.__str__()}]"
|
||||
@ -16,18 +15,17 @@ class Users:
|
||||
def import_into_db(self, db):
|
||||
cur = db.cursor()
|
||||
cur.execute(
|
||||
"""INSERT INTO users (userid, login, realname, email)
|
||||
VALUES (%s,%s,%s,%s) RETURNING id""",
|
||||
"""INSERT INTO users (userid, realname, email)
|
||||
VALUES (%s,%s,%s) RETURNING id""",
|
||||
(
|
||||
self.userid,
|
||||
self.login,
|
||||
self.realname,
|
||||
self.email,
|
||||
),
|
||||
)
|
||||
cur.close()
|
||||
|
||||
def user_lookup(self, db, userid):
|
||||
def user_lookup(db, userid):
|
||||
cur= db.cursor()
|
||||
cur.execute("SELECT * FROM users where userid=%s", (userid,))
|
||||
row = cur.fetchone()
|
||||
|
Loading…
Reference in New Issue
Block a user