<commit_before>package drt.shared

import java.util.Date

import drt.shared.FlightsApi._
import drt.shared.PassengerQueueTypes.PaxTypeAndQueueCounts
import drt.shared.PassengerSplits.{FlightNotFound, SplitsPaxTypeAndQueueCount, VoyagePaxSplits}
import drt.shared.SplitRatiosNs.SplitRatio

import scala.collection.immutable._
import scala.concurrent.Future


object DeskAndPaxTypeCombinations {
  val egate = "eGate"
  val deskEeaNonMachineReadable = "EEA NMR"
  val deskEea = "EEA"
  val nationalsDeskVisa = "VISA"
  val nationalsDeskNonVisa = "Non-VISA"
}

case class MilliDate(millisSinceEpoch: Long) extends Ordered[MilliDate] {
  def compare(that: MilliDate) = millisSinceEpoch.compare(that.millisSinceEpoch)
}

object FlightParsing {
  val iataRe = """(\w\w)(\d{1,4})(\w)?""".r

  def parseIataToCarrierCodeVoyageNumber(iata: String): Option[(String, String)] = {
    iata match {
      case iataRe(carriercode, voyageNumber, suffix) => Option((carriercode, voyageNumber))
      case what => None
    }
  }
}


sealed trait SplitStyle
case object PaxNumbers extends SplitStyle
case object Percentage extends SplitStyle

case class ApiSplits(splits: List[ApiPaxTypeAndQueueCount], source: String, splitStyle: SplitStyle = PaxNumbers)
case class ApiFlightWithSplits(apiFlight: Arrival, splits: List[ApiSplits])

case class Arrival(
                      Operator: String,
                      Status: String,
                      EstDT: String,
                      ActDT: String,
                      EstChoxDT: String,
                      ActChoxDT: String,
                      Gate: String,
                      Stand: String,
                      MaxPax: Int,
                      ActPax: Int,
                      TranPax: Int,
                      RunwayID: String,
                      BaggageReclaimId: String,
                      FlightID: Int,
                      AirportID: String,
                      Terminal: String,
                      rawICAO: String,
                      rawIATA: String,
                      Origin: String,
                      SchDT: String,
                      PcpTime: Long,
                      LastKnownPax: Option[Int] = None) {
  lazy val ICAO = Arrival.standardiseFlightCode(rawICAO)
  lazy val IATA = Arrival.standardiseFlightCode(rawIATA)
}

//This is used for handling historic snapshots, do not change or remove.
case class ApiFlight(
                      Operator: String,
                      Status: String,
                      EstDT: String,
                      ActDT: String,
                      EstChoxDT: String,
                      ActChoxDT: String,
                      Gate: String,
                      Stand: String,
                      MaxPax: Int,
                      ActPax: Int,
                      TranPax: Int,
                      RunwayID: String,
                      BaggageReclaimId: String,
                      FlightID: Int,
                      AirportID: String,
                      Terminal: String,
                      rawICAO: String,
                      rawIATA: String,
                      Origin: String,
                      SchDT: String,
                      PcpTime: Long)<commit_msg>DRT-4600 Use legacy serialisable id<commit_after>package drt.shared

import java.util.Date

import drt.shared.FlightsApi._
import drt.shared.PassengerQueueTypes.PaxTypeAndQueueCounts
import drt.shared.PassengerSplits.{FlightNotFound, SplitsPaxTypeAndQueueCount, VoyagePaxSplits}
import drt.shared.SplitRatiosNs.SplitRatio

import scala.collection.immutable._
import scala.concurrent.Future


object DeskAndPaxTypeCombinations {
  val egate = "eGate"
  val deskEeaNonMachineReadable = "EEA NMR"
  val deskEea = "EEA"
  val nationalsDeskVisa = "VISA"
  val nationalsDeskNonVisa = "Non-VISA"
}

case class MilliDate(millisSinceEpoch: Long) extends Ordered[MilliDate] {
  def compare(that: MilliDate) = millisSinceEpoch.compare(that.millisSinceEpoch)
}

object FlightParsing {
  val iataRe = """(\w\w)(\d{1,4})(\w)?""".r

  def parseIataToCarrierCodeVoyageNumber(iata: String): Option[(String, String)] = {
    iata match {
      case iataRe(carriercode, voyageNumber, suffix) => Option((carriercode, voyageNumber))
      case what => None
    }
  }
}


sealed trait SplitStyle
case object PaxNumbers extends SplitStyle
case object Percentage extends SplitStyle

case class ApiSplits(splits: List[ApiPaxTypeAndQueueCount], source: String, splitStyle: SplitStyle = PaxNumbers)
case class ApiFlightWithSplits(apiFlight: Arrival, splits: List[ApiSplits])

case class Arrival(
                      Operator: String,
                      Status: String,
                      EstDT: String,
                      ActDT: String,
                      EstChoxDT: String,
                      ActChoxDT: String,
                      Gate: String,
                      Stand: String,
                      MaxPax: Int,
                      ActPax: Int,
                      TranPax: Int,
                      RunwayID: String,
                      BaggageReclaimId: String,
                      FlightID: Int,
                      AirportID: String,
                      Terminal: String,
                      rawICAO: String,
                      rawIATA: String,
                      Origin: String,
                      SchDT: String,
                      PcpTime: Long,
                      LastKnownPax: Option[Int] = None) {
  lazy val ICAO = Arrival.standardiseFlightCode(rawICAO)
  lazy val IATA = Arrival.standardiseFlightCode(rawIATA)
}

//This is used for handling historic snapshots, do not change or remove.
@SerialVersionUID(-2103953769229068778L)
case class ApiFlight(
                      Operator: String,
                      Status: String,
                      EstDT: String,
                      ActDT: String,
                      EstChoxDT: String,
                      ActChoxDT: String,
                      Gate: String,
                      Stand: String,
                      MaxPax: Int,
                      ActPax: Int,
                      TranPax: Int,
                      RunwayID: String,
                      BaggageReclaimId: String,
                      FlightID: Int,
                      AirportID: String,
                      Terminal: String,
                      rawICAO: String,
                      rawIATA: String,
                      Origin: String,
                      SchDT: String,
                      PcpTime: Long){

  lazy val ICAO = ApiFlight.standardiseFlightCode(rawICAO)
  lazy val IATA = ApiFlight.standardiseFlightCode(rawIATA)


}
object ApiFlight {

  def standardiseFlightCode(flightCode: String): String = {
    val flightCodeRegex = "^([A-Z0-9]{2,3}?)([0-9]{1,4})([A-Z]?)$".r

    flightCode match {
      case flightCodeRegex(operator, flightNumber, suffix) =>
        f"${operator}${flightNumber.toInt}%04d${suffix}"
      case _ => flightCode
    }
  }
}

{'fraction_non_alphanumeric': 0.07771575783598111, 'fraction_numerical': 0.005295548876484901, 'mean_word_length': 1.6509863429438543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1080088', 'n_tokens_mistral': 2070, 'n_tokens_neox': 1914, 'n_words': 446}