#261 Post discussion link to bz on propose
Opened 2 years ago by frantisekz. Modified 7 days ago

@@ -27,8 +27,8 @@ 

  import json

  import itertools


- from blockerbugs import app, __version__

- from blockerbugs.util import bz_interface, pagure_bot, misc

+ from blockerbugs import app, db, __version__

+ from blockerbugs.util import bz_interface, pagure_bot, misc, discussion_sync, bug_sync

  from blockerbugs.models.bug import Bug

  from blockerbugs.models.milestone import Milestone

  from blockerbugs.models.update import Update
@@ -443,6 +443,19 @@ 


      return bz_interface.create_bugzilla()


+ def bugzilla_sync_proposal(bugid, milestone, blocker, fe):

+     # Fetch the proposed stuff into the database right away

+     sync = bug_sync.BugSync(db)

+     trackers_str = []

+     if blocker: trackers_str.append("Blocker")

+     if fe:      trackers_str.append("FreezeException")

+     sync.fetch_single_bug(milestone, bugid, trackers_str)


+     # Create a discussion ticket

+     discussion_sync.create_discussions_links(milestone, [misc.bug_from_db(bugid, milestone)])


+     # Cross-comment the voting ticket link to the bugzilla

+     bz_interface.comment_bz(misc.bug_from_db(bugid, milestone))


  @main.route('/propose_bug', methods=['GET', 'POST'])

@@ -500,6 +513,7 @@ 

                  user, bugid, proposal.get_tracker_type(), selected_milestone.name))


                  proposal.propose_bugs(user, selected_milestone.name, bugform.justification.data)

+                 bugzilla_sync_proposal(bugid, selected_milestone, bool(bugform.blocker.data), bool(bugform.freeze_exception.data))

                  return render_template('thanks.html', bugid=bugid,



@@ -150,6 +150,22 @@ 




+     def fetch_single_bug(self, milestone: Milestone, bugid, trackers) -> None:

+         self.log.info("Fetching bug data for %s" % bugid)

+         bug = self.bzinterface.bz.getbug(bugid)

+         oldbug = Bug.query.filter_by(bugid=bug.bug_id, milestone=milestone).first()


+         for tracker in trackers:

+             buginfo = self.extract_information(bug, tracker)

+             if oldbug:

+                 oldbug.update(buginfo, tracker, milestone)

+                 self.db.session.add(oldbug)

+             else:

+                 newbug = Bug.from_data(buginfo, milestone, tracker)

+                 self.db.session.add(newbug)


+         self.db.session.commit()


      def cleanup_milestone(self, milestone: Milestone, tracker_type: str) -> None:

          """'Clean up' all bugs under `tracker_type` in `milestone`, which are not currently blocking

          the relevant tracker ticket. Cleaning up means setting all those bugs as rejected

@@ -67,6 +67,12 @@ 

      url = '{uri.scheme}://{uri.netloc}'.format(uri=parsed_uri)

      return url


+ def comment_bz(bug):

+     bz = create_bugzilla()

+     comment = ["You can vote if this should be accepted as a Blocker and/or FreezeException",

+                " for", bug.milestone.name, " on: " , bug.discussion_link]

+     bug_update = bz.build_update(comment=' '.join(comment))

+     bz.update_bugs(bug.bugid, bug_update)


  class BZInterfaceError(Exception):

      """A custom wrapper for XMLRPC errors from Bugzilla"""

@@ -2,7 +2,7 @@ 


  from blockerbugs import db, app

  from blockerbugs.config import Config as bb_Config

- from blockerbugs.util import pagure_interface

+ from blockerbugs.util import pagure_interface, bz_interface

  from blockerbugs.models.milestone import Milestone

  from blockerbugs.models.release import Release

  from blockerbugs.models.bug import Bug
@@ -77,6 +77,7 @@ 

      for milestone in milestones:

          bugs = Bug.query.filter_by(bugid=bugid, milestone=milestone).all()

          create_discussions_links(milestone, bugs)

+         bz_interface.comment_bz(bugs[0])



  def close_discussions_inactive_releases(dry_run=False):

file modified
+4 -1
@@ -3,7 +3,7 @@ 

  from typing import Optional


  from blockerbugs import _version


+ from blockerbugs.models.bug import Bug


  def version_date() -> Optional[str]:

      """Return the date (just the date portion) of the app version identifier, as returned by
@@ -15,3 +15,6 @@ 

      parts = date.split(sep='T')

      assert len(parts) == 2

      return parts[0]


+ def bug_from_db(bugid, milestone):

+     return Bug.query.filter_by(bugid=bugid, milestone=milestone).first()

Fixes #148

Apart from that, it causes the proposed bugs to appear immediately in the blockerbugs app, without needing to wait up to 30 minutes for the next sync. Slightly increases time that it takes to process proposals.

rebased onto fb94f96

2 years ago

rebased onto 64a5246

2 years ago

Build succeeded.

rebased onto 1f49468

2 years ago

Build succeeded.

You should probably also handle situation when someone re-creates a discussion: https://pagure.io/fedora-qa/blockerbugs/blob/develop/f/blockerbugs/cli.py#_217

Build succeeded.

rebased onto f3ef31f

2 years ago

Build succeeded.

rebased onto 7bc8d08

2 years ago

rebased onto 6ceb861

2 years ago

Build succeeded.

Build succeeded.

rebased onto 798ad06

a year ago

rebased onto 3c35669

a year ago

@kparal This is now ready for review (note: I am yet to test this code after the recent refactoring, t should(tm) work).

One question comes to mind right now, where should bugzilla_crosspost be placed? It's currently in controllers.main which doesn't "feel right", do you have some ideas/opinions?

rebased onto 321eab4

6 months ago

@frantisekz Finally looking at it! 😇 If I understand the patch correctly, it only appends the discussion link for bugs proposed through the BBA web interface, but doesn't add it for bugs proposed manually, right?

@frantisekz Finally looking at it! 😇


If I understand the patch correctly, it only appends the discussion link for bugs proposed through the BBA web interface, but doesn't add it for bugs proposed manually, right?

It's been a year since I wrote the code, but from a quick re-look, no, it should add discussion links to all the proposed bugs, be it via the app or via bugzilla (see 'bz_interface.comment_bz(bugs[0])' added into the discussion sync loop).

rebased onto 41f1b78

3 months ago

rebased onto b9a2985

3 months ago

Now contains the split out #282 , which should go in first, if is this one to be merged or dropped as @kparal wanted to make adjustments in this part.