Skip to content

Commit 04b9271

Browse files
committed
brancher: insert stream name into the table
In preparation for more branchers insert stream name into the database. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent cc85723 commit 04b9271

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

deploy/contest/db

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ CREATE INDEX ON branches (branch DESC);
4949

5050
CREATE TABLE branches (
5151
branch varchar(80),
52+
stream varchar(60),
5253
t_date timestamp,
5354
base varchar(80),
5455
url varchar(200),

pw_brancher.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ def apply_local_patches(config, tree) -> List:
179179
def db_insert(config, state, name):
180180
global psql_conn
181181

182+
# Branches usually have a trailing separator
183+
pfx = config.get("target", "branch_pfx")[:-1]
182184
pub_url = config.get('target', 'public_url')
183185
row = {"branch": name,
184186
"date": state["branches"][name],
@@ -187,9 +189,11 @@ def db_insert(config, state, name):
187189
row |= state["info"][name]
188190

189191
with psql_conn.cursor() as cur:
190-
arg = cur.mogrify("(%s,%s,%s,%s,%s)", (row["branch"], row["date"], row["base"], row["url"],
191-
json.dumps(row)))
192-
cur.execute("INSERT INTO branches VALUES " + arg.decode('utf-8'))
192+
cols = "(branch, stream, t_date, base, url, info)"
193+
arg = cur.mogrify("(%s,%s,%s,%s,%s,%s)",
194+
(row["branch"], pfx, row["date"], row["base"],
195+
row["url"], json.dumps(row)))
196+
cur.execute(f"INSERT INTO branches {cols} VALUES " + arg.decode('utf-8'))
193197

194198

195199
def generate_deltas(config, tree, name):

0 commit comments

Comments
 (0)