## Bugs
- def get_bug_ids(self):
- return self.data.bug_ids
+ @lazy_property
+ def bug_ids(self):
+ rows = self.db.query("""
+ SELECT
+ bug_id
+ FROM
+ build_bugs
+ WHERE
+ build_id = %s
+ AND
+ removed_at IS NULL
+ ORDER BY
+ bug_id
+ """, self.id,
+ )
- def set_bug_ids(self, bug_ids):
- self._set_attribute("bug_ids", bug_ids or [])
+ return set([row.bug_id for row in rows])
- bug_ids = property(get_bug_ids, set_bug_ids)
+ def add_bug(self, bug_id, user=None):
+ self.db.execute("""
+ INSERT INTO
+ build_bugs
+ (
+ build_id,
+ bug_id,
+ added_by
+ )
+ VALUES
+ (
+ %s, %s, %s
+ )
+ ON CONFLICT
+ (
+ build_id,
+ bug_id
+ )
+ WHERE
+ removed_at IS NULL
+ DO NOTHING
+ """, self.id, bug_id, user,
+ )
- async def get_bugs(self):
- return await self.backend.bugzilla.get_bugs(self.bug_ids)
+ # Add to cache
+ self.bug_ids.add(bug_id)
- def _update_bugs_helper(self, repo):
- """
- This function takes a new status and generates messages that
- are appended to all bugs.
- """
+ def remove_bug(self, bug_id, user):
+ self.db.execute("""
+ UPDATE
+ build_bugs
+ SET
+ removed_at = CURRENT_TIMESTAMP,
+ removed_by = %s
+ WHERE
+ build_id = %s
+ AND
+ bug_id = %s
+ """, self.id, bug_id,
+ )
+
+ # Remove from cache
try:
- kwargs = BUG_MESSAGES[repo.type].copy()
+ self.bug_ids.remove(bug_id)
except KeyError:
- return
-
- baseurl = self.backend.settings.get("baseurl", "")
- args = {
- "build_url" : "%s/build/%s" % (baseurl, self.uuid),
- "distro_name" : self.distro.name,
- "package_name" : self.name,
- "repo_name" : repo.name,
- }
- kwargs["comment"] = kwargs["comment"] % args
-
- self.update_bugs(**kwargs)
-
- def _update_bug(self, bug_id, status=None, resolution=None, comment=None):
- self.db.execute("INSERT INTO builds_bugs_updates(bug_id, status, resolution, comment, time) \
- VALUES(%s, %s, %s, %s, NOW())", bug_id, status, resolution, comment)
+ pass
- def update_bugs(self, status, resolution=None, comment=None):
- # Update all bugs linked to this build.
- for bug_id in self.get_bug_ids():
- self._update_bug(bug_id, status=status, resolution=resolution, comment=comment)
+ async def get_bugs(self):
+ """
+ Fetch all bugs from Bugzilla
+ """
+ return await self.backend.bugzilla.get_bugs(self.bug_ids)
# Deprecation
# by_user
# builder
# repository
+# bug
# error
# points
#
builds.owner_id AS by_user,
NULL::integer AS builder,
NULL::integer AS repository,
+ NULL::integer AS bug,
NULL::text AS error,
NULL::integer AS points
FROM
NULL AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
builds.deleted_by AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
builds.deprecated_by AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
build_comments.user_id AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
NULL AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
NULL AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
UNION ALL
+ -- Bugs added to builds
+ SELECT
+ 'build-bug-added' AS type,
+ build_bugs.added_at AS t,
+ 4 AS priority,
+ build_bugs.build_id AS build,
+ NULL AS by_build,
+ NULL AS build_comment,
+ NULL AS build_group,
+ NULL AS job,
+ NULL AS mirror,
+ NULL AS user,
+ build_bugs.added_by AS by_user,
+ NULL AS builder,
+ NULL AS repository,
+ build_bugs.bug_id AS bug,
+ NULL AS error,
+ NULL AS points
+ FROM
+ build_bugs
+
+ UNION ALL
+
+ -- Bugs removed from builds
+
+ SELECT
+ 'build-bug-removed' AS type,
+ build_bugs.removed_at AS t,
+ 4 AS priority,
+ build_bugs.build_id AS build,
+ NULL AS by_build,
+ NULL AS build_comment,
+ NULL AS build_group,
+ NULL AS job,
+ NULL AS mirror,
+ NULL AS user,
+ build_bugs.removed_by AS by_user,
+ NULL AS builder,
+ NULL AS repository,
+ build_bugs.bug_id AS bug,
+ NULL AS error,
+ NULL AS points
+ FROM
+ build_bugs
+ WHERE
+ removed_at IS NOT NULL
+
+ UNION ALL
+
-- Build added to repository
SELECT
'repository-build-added' AS type,
repository_builds.added_by AS by_user,
NULL AS builder,
repository_builds.repo_id AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
repository_builds.removed_by AS by_user,
NULL AS builder,
repository_builds.repo_id AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
build_points.user_id AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
build_points.points AS points
FROM
NULL AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
NULL AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
NULL AS by_user,
jobs.builder_id AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
NULL AS by_user,
jobs.builder_id AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
jobs.aborted_by AS by_user,
jobs.builder_id AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
NULL AS by_user,
jobs.builder_id AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
NULL AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
mirrors.created_by AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
mirrors.deleted_by AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
NULL AS error,
NULL AS points
FROM
NULL AS by_user,
NULL AS builder,
NULL AS repository,
+ NULL AS bug,
mirror_status_changes.error AS error,
NULL AS points
FROM (
# Update the cache
build.repos.append(self)
- # Update bug status.
- #build._update_bugs_helper(self)
+ # Update bug status
+ # XXX TODO
# Update the repository
if update:
SET default_table_access_method = heap;
+--
+-- Name: build_bugs; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE public.build_bugs (
+ id integer NOT NULL,
+ build_id integer NOT NULL,
+ bug_id integer NOT NULL,
+ added_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ added_by integer,
+ removed_at timestamp without time zone,
+ removed_by integer
+);
+
+
--
-- Name: build_comments; Type: TABLE; Schema: public; Owner: -
--
);
+--
+-- Name: build_bugs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE public.build_bugs_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: build_bugs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE public.build_bugs_id_seq OWNED BY public.build_bugs.id;
+
+
--
-- Name: build_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
ALTER SEQUENCE public.builders_id_seq OWNED BY public.builders.id;
---
--- Name: builds_bugs_updates; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.builds_bugs_updates (
- id integer NOT NULL,
- bug_id integer NOT NULL,
- status text,
- resolution text,
- comment text,
- "time" timestamp without time zone NOT NULL,
- error boolean DEFAULT false NOT NULL,
- error_msg text
-);
-
-
---
--- Name: builds_bugs_updates_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE public.builds_bugs_updates_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-
---
--- Name: builds_bugs_updates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE public.builds_bugs_updates_id_seq OWNED BY public.builds_bugs_updates.id;
-
-
--
-- Name: builds_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
+--
+-- Name: build_bugs id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.build_bugs ALTER COLUMN id SET DEFAULT nextval('public.build_bugs_id_seq'::regclass);
+
+
--
-- Name: build_comments id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.builds ALTER COLUMN id SET DEFAULT nextval('public.builds_id_seq'::regclass);
---
--- Name: builds_bugs_updates id; Type: DEFAULT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.builds_bugs_updates ALTER COLUMN id SET DEFAULT nextval('public.builds_bugs_updates_id_seq'::regclass);
-
-
--
-- Name: distributions id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
+--
+-- Name: build_bugs build_bugs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.build_bugs
+ ADD CONSTRAINT build_bugs_pkey PRIMARY KEY (id);
+
+
--
-- Name: build_comments build_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ADD CONSTRAINT idx_2197954_primary PRIMARY KEY (id);
---
--- Name: builds_bugs_updates idx_2198008_primary; Type: CONSTRAINT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.builds_bugs_updates
- ADD CONSTRAINT idx_2198008_primary PRIMARY KEY (id);
-
-
--
-- Name: images_types idx_2198057_primary; Type: CONSTRAINT; Schema: public; Owner: -
--
ADD CONSTRAINT user_push_subscriptions_pkey PRIMARY KEY (id);
+--
+-- Name: build_bugs_unique; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE UNIQUE INDEX build_bugs_unique ON public.build_bugs USING btree (build_id, bug_id) WHERE (removed_at IS NULL);
+
+
--
-- Name: build_comments_build_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX user_push_subscriptions_user_id ON public.user_push_subscriptions USING btree (user_id) WHERE (deleted_at IS NULL);
+--
+-- Name: build_bugs build_bugs_added_by; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.build_bugs
+ ADD CONSTRAINT build_bugs_added_by FOREIGN KEY (added_by) REFERENCES public.users(id);
+
+
+--
+-- Name: build_bugs build_bugs_build_id; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.build_bugs
+ ADD CONSTRAINT build_bugs_build_id FOREIGN KEY (build_id) REFERENCES public.builds(id);
+
+
+--
+-- Name: build_bugs build_bugs_removed_by; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.build_bugs
+ ADD CONSTRAINT build_bugs_removed_by FOREIGN KEY (removed_by) REFERENCES public.users(id);
+
+
--
-- Name: build_groups build_groups_created_by; Type: FK CONSTRAINT; Schema: public; Owner: -
--
<p class="icon is-large has-text-danger">
<i class="fa-solid fa-2x fa-thumbs-down"></i>
</p>
+ {% elif event.type == "build-bug-added" %}
+ <p class="icon is-large has-text-success">
+ <i class="fa-solid fa-2x fa-bug"></i>
+ </p>
+ {% elif event.type == "build-bug-removed" %}
+ <p class="icon is-large has-text-danger">
+ <i class="fa-solid fa-2x fa-bug"></i>
+ </p>
{% elif event.type == "test-builds-succeeded" %}
<p class="icon is-large has-text-success">
<i class="fa-solid fa-2x fa-flask-vial"></i>
{{ _("%s started watching this build") % event.user }}
{% elif event.type == "build-watcher-removed" %}
{{ _("%s stopped watching this build") % event.user }}
+ {% elif event.type == "build-bug-added" %}
+ {{ _("Bug #%s has been added") % event.bug }}
+ {% elif event.type == "build-bug-removed" %}
+ {{ _("Bug #%s has been removed") % event.bug }}
{% elif event.type == "build-points" %}
{% if event.points > 0 %}
{{ _("This build has gained one point", "This build has gained %(points)s points", event.points) % { "points" : event.points } }}