async componentWillMount()

in src/content/components/GeneralTriage/GeneralTriage.js [172:244]


  async componentWillMount() {
    this._isMounted = true;
    await this.context.qm.runCachedQueries(
      this.getQueries(),
      () => this._isMounted,
      ({
        rsp: [
          { bugs: triageNeededBugs },
          { bugs: recentRegressionBugs },
          { bugs: needinfoBugs },
          { bugs: unassignedBugs },
        ],
        awaitingNetwork,
      }) => {
        const now = Date.now();
        const needinfoEscalatedBugs = [];
        const needinfoStaleBugs = [];
        for (const bug of needinfoBugs) {
          const needinfos = [];
          for (const flag of bug.flags) {
            if (flag.name === "needinfo") {
              flag.epoch = Date.parse(flag.creation_date);
              flag.age = Math.ceil((now - flag.epoch) / (1000 * 3600 * 24));
              needinfos.push(flag);
            }
          }
          bug.needinfos = needinfos.sort((a, b) => b.age - a.age);
          const relManNI = bug.needinfos.find(
            ni => ni.setter === "release-mgmt-account-bot@mozilla.tld"
          );
          const staleNI = bug.needinfos.find(
            ni => ni.setter !== ni.requestee && ni.age > 14
          );
          if (relManNI) {
            needinfoEscalatedBugs.push(addNeedinfoDetails(bug, relManNI));
          } else if (staleNI) {
            needinfoStaleBugs.push(addNeedinfoDetails(bug, staleNI));
          }
        }
        for (const set of [needinfoEscalatedBugs, needinfoStaleBugs]) {
          set.sort((a, b) => a.needinfo_epoch - b.needinfo_epoch);
        }

        const unassignedS1Bugs = [];
        const unassignedS2Bugs = [];
        for (const bug of unassignedBugs) {
          switch (bug.severity.toLowerCase()) {
            case "s1":
            case "blocker":
              unassignedS1Bugs.push(bug);
              break;
            case "s2":
            case "critical":
              unassignedS2Bugs.push(bug);
              break;
          }
        }

        this.setState({
          loaded: true,
          awaitingNetwork,
          bugs: {
            triageNeeded: triageNeededBugs,
            recentRegression: recentRegressionBugs,
            needinfoEscalated: needinfoEscalatedBugs,
            needinfoStale: needinfoStaleBugs,
            unassignedS1: unassignedS1Bugs,
            unassignedS2: unassignedS2Bugs,
          },
        });
      }
    );
  }