func()

in cmd/tc-collector/reportLoader.go [182:240]


func (t *Collector) loadInstallerInfo(builds []*Build, networkRequestCount int) error {
	var notLoadedInstallerBuildIds []*InstallerInfo
	for _, build := range builds {
		if build == nil {
			continue
		}

		id, buildTime, err := computeBuildDate(build)
		if err != nil {
			return err
		}

		if id == -1 {
			if t.config.HasInstallerField {
				t.logger.Error("cannot find installer build", "buildId", build.Id)
			}
			continue
		}

		installerInfo := t.installerBuildIdToInfo[id]
		if installerInfo == nil {
			installerInfo = &InstallerInfo{
				id:        id,
				buildTime: buildTime,
			}
			notLoadedInstallerBuildIds = append(notLoadedInstallerBuildIds, installerInfo)
			t.installerBuildIdToInfo[id] = installerInfo
		}
		build.installerInfo = installerInfo
	}

	if len(notLoadedInstallerBuildIds) == 0 {
		return nil
	}

	notLoadedIds := make([]int, 0, len(notLoadedInstallerBuildIds))
	for _, installerInfo := range notLoadedInstallerBuildIds {
		notLoadedIds = append(notLoadedIds, installerInfo.id)
	}
	t.logger.Debug("load installer info", "count", len(notLoadedInstallerBuildIds), "ids", notLoadedIds)

	errGroup, loadContext := errgroup.WithContext(t.taskContext)
	errGroup.SetLimit(networkRequestCount)
	for _, installerInfo := range notLoadedInstallerBuildIds {
		if installerInfo.id == -1 {
			continue
		}

		errGroup.Go(func() error {
			var err error
			installerInfo.changes, err = t.loadBuildChanges(loadContext, installerInfo.id)
			if err != nil {
				return fmt.Errorf("failed to load changes: %w", err)
			}
			return nil
		})
	}
	return errGroup.Wait()
}