mozilla-it / bugzilla-kanbanize

Sync Automation between Kanbanize and Mozilla
0 stars 1 forks source link

Unable to unassign bugs in either Kanbanize or Bugzilla. #4

Closed floatingatoll closed 8 years ago

floatingatoll commented 8 years ago

In short, we're simply comparing the assigned_to field on both sides to each other, and if either side is not unassigned, then it's assumed we wish to assign it.

floatingatoll commented 8 years ago

The Bugzilla history can be fetched from https://bugzilla.mozilla.org/rest/bug/$bugid/history?token=$BUGZILLA_TOKEN and the response looks like:

{
  "bugs": [
    {
      "history": [
        {
          "when": "2015-04-17T20:45:07Z",
          "who": "webops-kanban@mozilla.bugs",
          "changes": [
            {
              "removed": "",
              "added": "[kanban:https://webops.kanbanize.com/ctrl_board/2/969] ",
              "field_name": "whiteboard"
            }
          ]
        },
floatingatoll commented 8 years ago

The Kanbanize history can be fetched from http://$WHITEBOARD_TAG.kanbanize.com/index.php/api/kanbanize/get_task_details/boardid/$BOARD_ID/taskid/$card_id/format/json with parameter {"history":"yes","event":"update"} and the response looks like:

{
    "historydetails": [
    {
      "eventtype": "Updates",
      "historyevent": "Assignee changed",
      "details": "New assignee: smani",
      "author": "gozer",
      "entrydate": "2016-06-02 13:20:28",
      "historyid": "26266"
    },
floatingatoll commented 8 years ago

This is done, tested, and deployed.

The syncing theory here is "newer wins, older loses".

ed5a0d2 alters retrieve_card() to grab the history of updates to the card. 7690c28 adds new functions that grab the history of a bug.

5dc7e9f harnesses the existing code flow to insert new decision-making logic. Rather than altering the existing logic, it simply emits which it deems correct - card or bug - to the logfile.

While cards can have their assignee set to None, Bugzilla does not reasonably expect such things. Therefore, c543684 lets us reset the assignee to the default, which is reflected as None in kanban, and thus all syncing works correctly.

4fe9c9b removes the old logic, replacing it with the appropriate card or bug changes: If the card was set to Someone or None, set the bug to Someone or Default Assignee; If the bug was set to Someone or no one, set the card to Someone or None.

The last step, not documented here, is that the API key must be associated with an account in timezone UTC. Otherwise the time comparisons won't match Kanbanize, which offers no ability for us to determine the timezone of its timestamps. For whatever reason, they don't include the timezone, so this is an unavoidable complication.

floatingatoll commented 8 years ago

b057f28 updates sync-dist.cfg to document the UTC requirement.