Пример #1
0
func (c *rethinkClient) CreatePipelineRunStatus(id string, statusType pps.PipelineRunStatusType) error {
	runStatus := &pps.PipelineRunStatus{
		PipelineRunId:         id,
		PipelineRunStatusType: statusType,
		Timestamp:             prototime.TimeToTimestamp(c.timer.Now()),
	}
	data, err := marshaller.MarshalToString(runStatus)
	if err != nil {
		return err
	}
	_, err = c.pipelineRunStatuses.Insert(gorethink.JSON(data)).RunWrite(c.session)
	protolog.Debugf("created pipeline run status: %v\n", runStatus)
	return err
}
Пример #2
0
func includeAirline(airline *Airline, airlineCodeToAirlineIDToRouteIDs map[string]map[string]map[string]bool) (bool, error) {
	for _, code := range airline.Codes() {
		airlineID, ok := selectAirlineCodeToAirlineID[code]
		if ok {
			return airlineID == airline.Id, nil
		}
	}
	if !airline.Active {
		return false, nil
	}
	airlineCode, ok := filterAirlineIDToAirlineCode[airline.Id]
	if ok {
		if airline.Iata != airlineCode && airline.Icao != airlineCode {
			return false, fmt.Errorf("openflights: expected airline %v to have code %s", airline, airlineCode)
		}
		return false, nil
	}
	for _, code := range airline.Codes() {
		airlineIDToRouteIDs, ok := airlineCodeToAirlineIDToRouteIDs[code]
		if !ok {
			continue
		}
		airlineRouteIDs, ok := airlineIDToRouteIDs[airline.Id]
		numAirlineRouteIDs := 0
		if ok {
			numAirlineRouteIDs = len(airlineRouteIDs)
		}
		max := math.MinInt32
		maxAirlineID := ""
		for airlineID, routeIDs := range airlineIDToRouteIDs {
			if len(routeIDs) > max {
				max = len(routeIDs)
				maxAirlineID = airlineID
			}
		}
		if maxAirlineID != airline.Id {
			protolog.Debugf("filtering airline %v because it only had %d routes when max was airline id %s with %d", airline, numAirlineRouteIDs, maxAirlineID, max)
			return false, nil
		}
	}
	return true, nil
}