Skip to content

Commit

Permalink
brancher: insert stream name into the table
Browse files Browse the repository at this point in the history
In preparation for more branchers insert stream name
into the database.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
kuba-moo committed Feb 16, 2025
1 parent cc85723 commit 8ca1763
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions deploy/contest/db
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CREATE INDEX ON branches (branch DESC);

CREATE TABLE branches (
branch varchar(80),
stream varchar(60),
t_date timestamp,
base varchar(80),
url varchar(200),
Expand Down
9 changes: 6 additions & 3 deletions pw_brancher.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def apply_local_patches(config, tree) -> List:
def db_insert(config, state, name):
global psql_conn

pfx = config.get("target", "branch_pfx")
pub_url = config.get('target', 'public_url')
row = {"branch": name,
"date": state["branches"][name],
Expand All @@ -187,9 +188,11 @@ def db_insert(config, state, name):
row |= state["info"][name]

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


def generate_deltas(config, tree, name):
Expand Down

0 comments on commit 8ca1763

Please sign in to comment.