<commit_before>var airlineCategory = require( '../airline-category' )
var flightStatus = require( '../flight-status' )
var serviceType = require( '../service-type' )
var codeshareType = require( '../codeshare-type' )

function formatAirline( airline ) {
  airline.category = airlineCategory[ airline.category ] ||
    { code: airline.category }
  return airline
}

function formatCodeShare( codeShare ) {

  var data = {}

  data.flightNumber = codeShare.flightNumber
  data.airline = formatAirline( codeShare.carrier )
  data.relationship = codeShare.relationship &&
    codeshareType[ codeShare.relationship ] ||
    { code: codeShare.relationship }

  return data

}

function formatFlight( flight ) {

    var data = {
      flightId: flight.flightId,
      flightNumber: flight.flightNumber,
      flightType: serviceType[ flight.schedule.flightType ] || { code: flight.schedule.flightType },
      serviceClasses: [],
      restrictions: [],
      status: {
        code: flight.status,
        description: flightStatus[ flight.status ],
      },
      arrival: {
        date: flight.arrivalDate.dateUtc,
        tzRegion: flight.arrivalAirport.timeZoneRegionName,
        tzOffset: flight.arrivalAirport.utcOffsetHours,
        gateDelay: void 0,
        gateTime: {},
        runwayDelay: void 0,
        runwayTime: {},
        gate: flight.airportResources.arrivalGate,
        terminal: flight.airportResources.arrivalTerminal,
        baggageClaim: flight.airportResources.arrivalBaggage,
        airport: flight.arrivalAirport,
      },
      departure: {
        date: flight.departureDate.dateUtc,
        tzRegion: flight.departureAirport.timeZoneRegionName,
        tzOffset: flight.departureAirport.utcOffsetHours,
        gateDelay: void 0,
        gateTime: {},
        runwayDelay: void 0,
        runwayTime: {},
        gate: flight.airportResources.departureGate,
        terminal: flight.airportResources.departureTerminal,
        airport: flight.departureAirport,
      },
      carrier: {
        airline: formatAirline( flight.carrier ),
        primary: flight.primaryCarrier && formatAirline( flight.primaryCarrier ),
        operating: flight.operatingCarrier && formatAirline( flight.operatingCarrier ),
      },
      codeshares: ( flight.codeshares || [] ).map( formatCodeShare ),
      duration: {},
    }

    // TODO:
    data.serviceClasses = flight.schedule.serviceClasses.split( '' )
      // .map( function( serviceClass ) {
      //   return serviceType[ serviceClass ] || { code: serviceClass }
      // })

    // TODO:
    data.restrictions = flight.schedule.restrictions.split( '' )
      // .map( function( restrictionClass ) {
      //   return restrictionType[ restrictionClass ] || { code: restrictionClass }
      // })

    // Times: Gate
    if( flight.operationalTimes ) {

      if( flight.operationalTimes.flightPlanPlannedArrival )
        data.arrival.gateTime.planned = flight.operationalTimes.flightPlanPlannedArrival.dateUtc

      if( flight.operationalTimes.publishedArrival )
        data.arrival.gateTime.published = flight.operationalTimes.publishedArrival.dateUtc

      if( flight.operationalTimes.scheduledGateArrival )<commit_msg>Update format/status: Fix for undefined `airportResources`<commit_after>var airlineCategory = require( '../airline-category' )
var flightStatus = require( '../flight-status' )
var serviceType = require( '../service-type' )
var codeshareType = require( '../codeshare-type' )

function formatAirline( airline ) {
  airline.category = airlineCategory[ airline.category ] ||
    { code: airline.category }
  return airline
}

function formatCodeShare( codeShare ) {

  var data = {}

  data.flightNumber = codeShare.flightNumber
  data.airline = formatAirline( codeShare.carrier )
  data.relationship = codeShare.relationship &&
    codeshareType[ codeShare.relationship ] ||
    { code: codeShare.relationship }

  return data

}

function formatFlight( flight ) {

    var data = {
      flightId: flight.flightId,
      flightNumber: flight.flightNumber,
      flightType: serviceType[ flight.schedule.flightType ] || { code: flight.schedule.flightType },
      serviceClasses: [],
      restrictions: [],
      status: {
        code: flight.status,
        description: flightStatus[ flight.status ],
      },
      arrival: {
        date: flight.arrivalDate.dateUtc,
        tzRegion: flight.arrivalAirport.timeZoneRegionName,
        tzOffset: flight.arrivalAirport.utcOffsetHours,
        gateDelay: void 0,
        gateTime: {},
        runwayDelay: void 0,
        runwayTime: {},
        gate: void 0,
        terminal: void 0,
        baggageClaim: void 0,
        airport: flight.arrivalAirport,
      },
      departure: {
        date: flight.departureDate.dateUtc,
        tzRegion: flight.departureAirport.timeZoneRegionName,
        tzOffset: flight.departureAirport.utcOffsetHours,
        gateDelay: void 0,
        gateTime: {},
        runwayDelay: void 0,
        runwayTime: {},
        gate: void 0,
        terminal: void 0,
        airport: flight.departureAirport,
      },
      carrier: {
        airline: formatAirline( flight.carrier ),
        primary: flight.primaryCarrier && formatAirline( flight.primaryCarrier ),
        operating: flight.operatingCarrier && formatAirline( flight.operatingCarrier ),
      },
      codeshares: ( flight.codeshares || [] ).map( formatCodeShare ),
      duration: {},
    }

    if( flight.airportResources ) {
      data.arrival.gate = flight.airportResources.arrivalGate
      data.arrival.terminal = flight.airportResources.arrivalTerminal
      data.arrival.baggageClaim = flight.airportResources.arrivalBaggage
      data.departure.gate = flight.airportResources.departureGate
      data.departure.terminal = flight.airportResources.departureTerminal
    }

    // TODO:
    data.serviceClasses = flight.schedule.serviceClasses.split( '' )
      // .map( function( serviceClass ) {
      //   return serviceType[ serviceClass ] || { code: serviceClass }
      // })

    // TODO:
    data.restrictions = flight.schedule.restrictions.split( '' )
      // .map( function( restrictionClass ) {
      //   return restrictionType[ restrictionClass ] || { code: restrictionClass }
      // })

    // Times: Gate
    if( flight.operationalTimes ) {

      if( flight.operationalTimes.flightPlanPlannedArrival )
        data.arrival.gateTime.planned = flight.operationalTimes.flightPlanPlannedArrival.dateUtc

      if( flight.operationalTimes.publishedArrival )
        data.arrival.gateTime.published = flight.operationalTimes.publishedArrival.dateUtc

      if( flight.operationalTimes.scheduledGateArrival )
{'fraction_non_alphanumeric': 0.10780056894744722, 'fraction_numerical': 0.0019463991615511305, 'mean_word_length': 2.883720930232558, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6773836', 'n_tokens_mistral': 1994, 'n_tokens_neox': 1887, 'n_words': 348}