Add new scheme application
This commit is contained in:
2
db.py
2
db.py
@@ -96,6 +96,7 @@ class IncomeBranch(Base):
|
|||||||
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'))
|
user_id: Mapped[int] = mapped_column(ForeignKey('users.id'))
|
||||||
scheme: Mapped[str]
|
scheme: Mapped[str]
|
||||||
branch: Mapped[str]
|
branch: Mapped[str]
|
||||||
|
local_scheme: Mapped[str]
|
||||||
|
|
||||||
user: Mapped['User'] = relationship(back_populates='income_branches')
|
user: Mapped['User'] = relationship(back_populates='income_branches')
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ class IncomeBranch(Base):
|
|||||||
'id': self.id,
|
'id': self.id,
|
||||||
'scheme': self.scheme,
|
'scheme': self.scheme,
|
||||||
'branch': self.branch,
|
'branch': self.branch,
|
||||||
|
'local_scheme': self.local_scheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
8
main.py
8
main.py
@@ -67,8 +67,8 @@ def get_branch(bndname: str, scheme: str):
|
|||||||
with Session(conn) as session:
|
with Session(conn) as session:
|
||||||
item = session.query(db.IncomeBranch).filter_by(scheme=scheme).join(db.User).filter_by(bndname=bndname).one_or_none()
|
item = session.query(db.IncomeBranch).filter_by(scheme=scheme).join(db.User).filter_by(bndname=bndname).one_or_none()
|
||||||
if item:
|
if item:
|
||||||
return item.branch
|
return item.branch,item.local_scheme
|
||||||
return None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
def run_tasks():
|
def run_tasks():
|
||||||
@@ -570,7 +570,9 @@ def apply_commits(params, files, url):
|
|||||||
repl = req.find('replication')
|
repl = req.find('replication')
|
||||||
scheme = repl.get('scheme')
|
scheme = repl.get('scheme')
|
||||||
commit = repl.get('id')
|
commit = repl.get('id')
|
||||||
branch = get_branch(params['from'].replace('tcp://', ''), scheme)
|
branch, new_scheme = get_branch(params['from'].replace('tcp://', ''), scheme)
|
||||||
|
if new_scheme:
|
||||||
|
scheme = new_scheme
|
||||||
if branch:
|
if branch:
|
||||||
logging.warning(branch)
|
logging.warning(branch)
|
||||||
con = OOConnectionParams(scheme, Config.oodb_host, Config.oodb_port, Config.oodb_dbname,
|
con = OOConnectionParams(scheme, Config.oodb_host, Config.oodb_port, Config.oodb_dbname,
|
||||||
|
|||||||
Reference in New Issue
Block a user