mozilla / bugzy

A bugzilla client for the Activity Stream Team
https://www.bugzy.org
10 stars 13 forks source link

Instead of maintaining a hard-coded list of iterations, get the list from BMO #227

Closed aminomancer closed 1 year ago

aminomancer commented 1 year ago

Using this query: https://bugzilla.mozilla.org/rest/field/bug/cf_fx_iteration

aminomancer commented 1 year ago

This is what the iterations look like in the response.

{
  "values": [
    {
      "name": "110.1 - Dec 12 - Dec 23",
      "visibility_values": [],
      "sort_key": 3460,
      "sortkey": 3460
    },
    {
      "visibility_values": [],
      "sort_key": 3470,
      "sortkey": 3470,
      "name": "110.2 - Dec 26 - Jan 6"
    },
    {
      "name": "110.3 - Jan 9 - Jan 13",
      "sortkey": 3480,
      "sort_key": 3480,
      "visibility_values": []
    }
  ]
}

So we will basically need to parse the name property into the version string, start date, end date, and length of the period (in weeks).

One question is when iterations should be built. If we're now automating the process, it seems lame to have to do a new deployment every time the iterations need to be updated. New iterations aren't added frequently, but they're not added predictably either. We want it to catch one-off changes like the addition of the one-week 110.3 iteration. I think it makes sense for the server to query this information like, once per day or something. It's not that costly. So, I think the iterations list should probably just be held in memory?

aminomancer commented 1 year ago

Also, a problem is determining the year from the name property. It only gives a range in what amounts to English shorthand MD - MD, and the years just need to be inferred. What's the most elegant way to do that? We could just assign a starting epoch (we already kinda do that) and increment the year every time we see a month that appears earlier than the previous month (like Dec to Jan). Thankfully, BMO already sorts the array for us. But maybe there's a better trick for that.

aminomancer commented 1 year ago

Alternatively, we could add a Refresh iterations link to the page similar to the Refresh metabugs one we already have. That's also kinda lame but it saves us needing to make all the iteration lookup functions async.

aminomancer commented 1 year ago

Example input iterations from Bugzilla:

"---",
"67.1 - Jan 28 - Feb 10",
"117.1 - July 3 - 14",
"118.1 - July 31 - Aug 11",
"118.2 - Aug 14 - Aug 25",
"119.1 - Aug 28 - Sept 8",
"119.2 - Sept 11 - Sept 22"

Example output lookup table:

{
  "byDate": {
    "2023-08-28": "119.1",
    "2023-09-04": "119.1",
    "2023-09-11": "119.2",
    "2023-09-18": "119.2",
    "2023-09-25": "120.1",
    "2023-10-02": "120.1",
    "2023-10-09": "120.2",
    "2023-10-16": "120.2",
    "2023-10-23": "120.2",
  },
  "byVersionString": {
    "119.1": {
      "startDate": "2023-08-28T00:00:00.000-07:00",
      "weeks": 2,
      "endDate": "2023-09-10T00:00:00.000-07:00",
    },
    "119.2": {
      "startDate": "2023-09-11T00:00:00.000-07:00",
      "weeks": 2,
      "endDate": "2023-09-24T00:00:00.000-07:00",
    },
    "120.1": {
      "startDate": "2023-09-25T00:00:00.000-07:00",
      "weeks": 2,
      "endDate": "2023-10-08T00:00:00.000-07:00",
    },
    "120.2": {
      "startDate": "2023-10-09T00:00:00.000-07:00",
      "weeks": 3,
      "endDate": "2023-10-29T00:00:00.000-07:00",
    },
  },
  "orderedVersionStrings": [
    "119.1",
    "119.2",
    "120.1",
    "120.2",
  ],
}