1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import sqlalchemy as sa
17 import sqlalchemy.exc
18 from buildbot.db import base
19
21
22
24 def thd(conn):
25 transaction = conn.begin()
26 tbl = self.db.model.scheduler_changes
27 ins_q = tbl.insert()
28 upd_q = tbl.update(
29 ((tbl.c.objectid == objectid)
30 & (tbl.c.changeid == sa.bindparam('wc_changeid'))))
31 for changeid, important in classifications.items():
32
33
34 imp_int = important and 1 or 0
35 try:
36 conn.execute(ins_q,
37 objectid=objectid,
38 changeid=changeid,
39 important=imp_int)
40 except (sqlalchemy.exc.ProgrammingError,
41 sqlalchemy.exc.IntegrityError):
42
43 conn.execute(upd_q,
44 wc_changeid=changeid,
45 important=imp_int)
46
47 transaction.commit()
48 return self.db.pool.do(thd)
49
51 def thd(conn):
52 sch_ch_tbl = self.db.model.scheduler_changes
53 wc = (sch_ch_tbl.c.objectid == objectid)
54 if less_than is not None:
55 wc = wc & (sch_ch_tbl.c.changeid < less_than)
56 q = sch_ch_tbl.delete(whereclause=wc)
57 conn.execute(q)
58 return self.db.pool.do(thd)
59
62 def thd(conn):
63 sch_ch_tbl = self.db.model.scheduler_changes
64 ch_tbl = self.db.model.changes
65
66 wc = (sch_ch_tbl.c.objectid == objectid)
67 if branch is not self.Thunk:
68 wc = wc & (
69 (sch_ch_tbl.c.changeid == ch_tbl.c.changeid) &
70 (ch_tbl.c.branch == branch))
71 q = sa.select(
72 [ sch_ch_tbl.c.changeid, sch_ch_tbl.c.important ],
73 whereclause=wc)
74 return dict([ (r.changeid, [False,True][r.important])
75 for r in conn.execute(q) ])
76 return self.db.pool.do(thd)
77