async componentWillMount()

in src/content/components/JiraView/JiraView.js [73:153]


  async componentWillMount() {
    this._isMounted = true;
    await this.context.qm.runCachedQueries(
      [
        {
          include_fields: includeFields,
          resolution: "---",
          order: "cf_fx_points DESC, priority, changeddate DESC",
          rules: [
            { key: "keywords", operator: "notsubstring", value: "meta" },
            {
              operator: "OR",
              rules: [
                {
                  key: "blocked",
                  operator: "anywordssubstr",
                  value: this.context.metas.map(m => m.id).join(","),
                },
                {
                  key: "component",
                  operator: "anyexact",
                  value: BUGZILLA_TRIAGE_COMPONENTS.join(","),
                },
              ],
            },
            {
              key: "cf_fx_iteration",
              operator: "notequals",
              value: "---",
            },
            {
              key: "see_also",
              operator: "substring",
              value: "mozilla-hub.atlassian.net/browse/OMC-",
            },
          ],
        },
      ],
      () => this._isMounted,
      ({ rsp: [{ bugs }], awaitingNetwork }) => {
        let allJiraTickets = {};
        for (let bug of bugs) {
          // take bugs from the current release
          const bugRelease = bug.cf_fx_iteration.split(".")[0];
          if (
            parseInt(bugRelease, 10) > this.props.release ||
            parseInt(bugRelease, 10) < this.props.release - 1
          ) {
            continue;
          }
          if (bug.see_also) {
            for (const url of bug.see_also) {
              let ticket = url.match(
                /mozilla-hub.atlassian.net\/browse\/(OMC-\d+)/
              );
              if (ticket) {
                let jiraTicket = ticket[1];
                bug.ticket = jiraTicket;
                allJiraTickets[jiraTicket] = allJiraTickets[jiraTicket] || [];
                allJiraTickets[jiraTicket].push(bug);
              }
            }
          }
        }

        for (const ticket of Object.keys(allJiraTickets)) {
          // sort bugs by points first, then by priority
          allJiraTickets[ticket].sort(
            (a, b) =>
              comparePoints(a.cf_fx_points, b.cf_fx_points) ||
              comparePriority(a.priority, b.priority)
          );
        }
        this.setState({
          loaded: true,
          awaitingNetwork,
          allJiraTickets,
        });
      }
    );
  }