def getresults(self, sourcecity, destinationcity, journeydate, trainclass='3A', flightclass='economy', numberofadults=1):

        logger.debug("[START]-Get Results From FlightBigNearApi for Source:[%s] to Destination:[%s] on JourneyDate:[%s] ", sourcecity, destinationcity, journeydate)

        with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:

            source = TravelPlanner.startuputil.gettraincity(sourcecity).title()
            destination = TravelPlanner.startuputil.gettraincity(destinationcity).title()

            airports = flightutil.getnearestairports(source, destination)
            sourcenear = airports.sourceairports.near
            sourcebig = airports.sourceairports.big
            destinationnear = airports.destinationairports.near

            if sourcenear == destinationnear:
                logger.warning("Nearest airports to source [%s] and destination [%s] are same [%s]. Hence no flight journey possible", source, destination, sourcenear)
                return {"flight": []}
            elif source == sourcebig:
                logger.warning("Source city [%s] is same as source big airport [%s]", source, sourcebig)
                return {"flight": []}
            elif sourcenear == sourcebig:
                logger.warning("Big and nearest airports [%s] of source [%s] are same", sourcebig, sourcecity)
                return {"flight": []}
            elif sourcebig == destination:
                logger.warning("Source Big airport [%s] is same as destination [%s]", sourcebig, destination)
                return {"flight": []}

            logger.debug("Fetching direct flights possible between sourcebig [%s] and destinationnear [%s] on [%s]", sourcebig, destinationnear, journeydate)

            if source != sourcebig:
                othermodesinitfuture = executor.submit(flightutil.getothermodes, sourcecity, sourcebig, journeydate, logger, trainclass,numberofadults)
            if destination != destinationnear:
                othermodesendfuture = executor.submit(flightutil.getothermodes, destinationnear, destinationcity, journeydate, logger, trainclass,numberofadults)

            directflightfuture = executor.submit(flightSkyScanner.getApiResults, sourcebig, destinationnear, journeydate, "flightnearbig", flightclass, numberofadults)
            directflightnextdayfuture = executor.submit(flightSkyScanner.getApiResults, sourcebig, destinationnear,(datetime.datetime.strptime(journeydate, '%d-%m-%Y') + datetime.timedelta(days=1)).strftime('%d-%m-%Y'), "flightnearbignextday", flightclass, numberofadults)

            directflight = directflightfuture.result()
            directflight = miscUtility.limitResults(directflight, "flight", limit=20)
            directflightnextday = directflightnextdayfuture.result()
            directflightnextday = miscUtility.limitResults(directflightnextday, "flight", limit=20)
            directflight['flight'].extend(directflightnextday['flight'])

            if len(directflight["flight"]) == 0:
                logger.warning("No flight available between sourcenear [%s] and destinationnear [%s] on [%s]", sourcenear, destinationnear, journeydate)
                return directflight

            if source != sourcebig and destination != destinationnear:
                othermodessminit = othermodesinitfuture.result()
                othermodessmend = othermodesendfuture.result()
                directflight = flightutil.getmixandmatchresult(othermodessminit, othermodessmend, copy.deepcopy(directflight), logger)
            elif source != sourcebig:
                othermodessminit = othermodesinitfuture.result()
                directflight = flightutil.getmixandmatchendresult(othermodessminit, copy.deepcopy(directflight), logger)
            elif destination != destinationnear:
                othermodessmend = othermodesendfuture.result()
                directflight = flightutil.getmixandmatchinitresult(othermodessmend, copy.deepcopy(directflight), logger)
            return directflight
    def getresults(self, sourcecity, destinationcity, journeydate, flightclass,
                   numberofadults):

        logger.debug(
            "[START]-Get Results From FlightDirectApi for Source:[%s] to Destination:[%s] on JourneyDate:[%s] ",
            sourcecity, destinationcity, journeydate)

        with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:

            source = TravelPlanner.startuputil.gettraincity(sourcecity).title()
            destination = TravelPlanner.startuputil.gettraincity(
                destinationcity).title()

            airports = flightutil.getnearestairports(source, destination)
            sourcenear = airports.sourceairports.near
            destinationnear = airports.destinationairports.near

            if source != sourcenear and destination != destinationnear:
                logger.warning(
                    "No direct flight possible between source [%s] and destination [%s]",
                    source, destination)
                return {"flight": []}
            else:
                logger.debug(
                    "Fetching direct possible flights between source [%s] and destination [%s] on [%s]",
                    source, destination, journeydate)
                onlyflightfuture = executor.submit(
                    flightSkyScanner.getApiResults, source, destination,
                    journeydate, "flightdirect", flightclass, numberofadults)
                onlyflight = onlyflightfuture.result()
                onlyflight = miscUtility.limitResults(onlyflight, "flight")
                return onlyflight
Beispiel #3
0
    def mixAndMatchEnd(self, mixedflightend, otherModesInit, otherModesInit2):

        """
        Join flight with other modes, with flight in the end
        :param mixedflightend: flight part of journey
        :param otherModesInit: other mode of journey
        :param otherModesInit2: other mode of jounrey2
        :return: combined journey with flight after other mode of total journey
        """
        logger.debug("[START]")
        mixedflightend = miscUtility.limitResults(mixedflightend, "flight")
        otherModesInit=otherModesInit+otherModesInit2
        for j in range(len(mixedflightend["flight"])):
            flightpart = mixedflightend["flight"][j]["parts"][0]
            subparts = []
            for k in range(len(otherModesInit)):
                subpart = otherModesInit[k]["parts"][0]
                if dateTimeUtility.checkIfApplicable(subpart["arrival"], subpart["arrivalDate"],flightpart["departure"], flightpart["departureDate"], 3):
                    subpart["waitingTime"] = dateTimeUtility.getWaitingTime(subpart["arrival"], flightpart["departure"],subpart["arrivalDate"],flightpart["departureDate"])
                    subpart["subJourneyTime"] = dateTimeUtility.gettotalduration(dateTimeUtility.convertflighttime(flightpart["departure"]), subpart["departure"], flightpart["departureDate"], subpart["departureDate"])
                    subparts.append(copy.deepcopy(subpart))

            if len(subparts) > 5:
                subparts.sort(miscUtility.sortonsubjourneytime)
                subparts = subparts[0:5]

            if subparts:
                minmax = minMaxUtil.getMinMaxValues(subparts)
                newpart = {"subParts": subparts, "mode": subparts[0]["mode"],"id": mixedflightend["flight"][j]["full"][0]["id"] + str(0), "destination": subparts[0]["destination"],
                           "source": subparts[0]["source"],"carrierName": subparts[0]["carrierName"]}
                flightpart["id"]=mixedflightend["flight"][j]["full"][0]["id"] + str(1)
                mixedflightend["flight"][j]["parts"].insert(0,newpart)
                mixedflightend["flight"][j]["full"][0]["route"] = newpart["source"] + ","+subparts[0]["mode"]+"," + newpart["destination"] + ",flight," + flightpart["destination"]
                mixedflightend["flight"][j]["full"][0]["price"] = int(mixedflightend["flight"][j]["full"][0]["price"]) + int(minMaxUtil.getprice(subparts[0]))
                mixedflightend["flight"][j]["full"][0]["minPrice"] = int(mixedflightend["flight"][j]["full"][0]["minPrice"]) +  int(minmax["minPrice"])
                mixedflightend["flight"][j]["full"][0]["maxPrice"] = int(mixedflightend["flight"][j]["full"][0]["maxPrice"] ) + int(minmax["maxPrice"])
                mixedflightend["flight"][j]["full"][0]["duration"] = dateTimeUtility.addDurations(mixedflightend["flight"][j]["full"][0]["duration"], subparts[0]["subJourneyTime"])
                mixedflightend["flight"][j]["full"][0]["minDuration"] = dateTimeUtility.addDurations(mixedflightend["flight"][j]["full"][0]["minDuration"], minmax["minDuration"])
                mixedflightend["flight"][j]["full"][0]["maxDuration"] = dateTimeUtility.addDurations(mixedflightend["flight"][j]["full"][0]["maxDuration"], minmax["maxDuration"])
                mixedflightend["flight"][j]["full"][0]["minDeparture"] = minmax["minDep"]
                mixedflightend["flight"][j]["full"][0]["maxDeparture"] = minmax["maxDep"]
                mixedflightend["flight"][j]["full"][0]["source"] = subparts[0]["source"]
                mixedflightend["flight"][j]["full"][0]["waitingTime"] = subparts[0]["waitingTime"]
                mixedflightend["flight"][j]["full"][0]["departure"] = subparts[0]["departure"]
                mixedflightend["flight"][j]["full"][0]["departureDate"] = subparts[0]["departureDate"]
                mixedflightend["flight"][j]["full"][0]["departureDay"] = models.getdayabbrevationfromdatestr(subparts[0]["departureDate"], 0)
                mixedflightend["flight"][j]["full"][0]["arrivalDay"] = models.getdayabbrevationfromdatestr(flightpart["arrivalDate"], 0)

        mixedflightend["flight"] = [x for x in mixedflightend["flight"] if len(x["parts"]) == 2]
        logger.debug("[END]")
        return mixedflightend
Beispiel #4
0
def mixandmatchinit(mixedflightinit, othermodesend, logger):
    """
    Join flight journey with other modes, with flight being first part of combined journey
    :param mixedflightinit: flight part of journey
    :param othermodesend: other mode of journey
    :param otherModesEnd2: other mode of journey2
    :return: combined journey flight followed by other mode
    """
    logger.debug("[START] flight + othermodesend")
    mixedflightinit = miscUtility.limitResults(mixedflightinit, "flight")

    for j in range(len(mixedflightinit["flight"])):
        flightpart = mixedflightinit["flight"][j]["parts"][0]
        subparts = []
        for k in range(len(othermodesend)):
            subpart = othermodesend[k]["parts"][0]
            if dateTimeUtility.isjourneypossible(
                    dateTimeUtility.convertflighttime(flightpart["arrival"]),
                    subpart["departure"], flightpart["arrivalDate"],
                    subpart["departureDate"], 3, 24):
                subpart["waitingTime"] = dateTimeUtility.getWaitingTime(
                    flightpart["arrival"], subpart["departure"],
                    flightpart["arrivalDate"], subpart["departureDate"])
                subpart["subJourneyTime"] = dateTimeUtility.gettotalduration(
                    subpart["arrival"],
                    dateTimeUtility.convertflighttime(flightpart["arrival"]),
                    subpart["arrivalDate"], flightpart["arrivalDate"])
                subparts.append(copy.deepcopy(subpart))
        subparts.sort(miscUtility.sortonsubjourneytime)
        if len(subparts) > 5:
            subparts = subparts[0:5]

        if subparts:
            minmax = minMaxUtil.getMinMaxValues(subparts)
            newpart = {
                "subParts": subparts,
                "mode": subparts[0]["mode"],
                "id": mixedflightinit["flight"][j]["full"][0]["id"] + str(1),
                "destination": subparts[0]["destination"],
                "source": subparts[0]["source"],
                "carrierName": subparts[0]["carrierName"]
            }
            mixedflightinit["flight"][j]["parts"].append(newpart)
            mixedflightinit["flight"][j]["full"][0][
                "route"] = flightpart["source"] + ",flight," + flightpart[
                    "destination"] + "," + subparts[0]["mode"] + "," + newpart[
                        "destination"]
            mixedflightinit["flight"][j]["full"][0]["price"] = int(
                mixedflightinit["flight"][j]["full"][0]["price"]) + int(
                    minMaxUtil.getprice(subparts[0]))
            mixedflightinit["flight"][j]["full"][0]["minPrice"] = int(
                mixedflightinit["flight"][j]["full"][0]["minPrice"]) + int(
                    minmax["minPrice"])
            mixedflightinit["flight"][j]["full"][0]["maxPrice"] = int(
                mixedflightinit["flight"][j]["full"][0]["maxPrice"]) + int(
                    minmax["maxPrice"])
            mixedflightinit["flight"][j]["full"][0][
                "duration"] = dateTimeUtility.addDurations(
                    mixedflightinit["flight"][j]["full"][0]["duration"],
                    subparts[0]["subJourneyTime"])
            mixedflightinit["flight"][j]["full"][0][
                "minDuration"] = dateTimeUtility.addDurations(
                    mixedflightinit["flight"][j]["full"][0]["minDuration"],
                    minmax["minDuration"])
            mixedflightinit["flight"][j]["full"][0][
                "maxDuration"] = dateTimeUtility.addDurations(
                    mixedflightinit["flight"][j]["full"][0]["maxDuration"],
                    minmax["maxDuration"])
            mixedflightinit["flight"][j]["full"][0]["minArrival"] = minmax[
                "minArr"]
            mixedflightinit["flight"][j]["full"][0]["maxArrival"] = minmax[
                "maxArr"]
            mixedflightinit["flight"][j]["full"][0]["destination"] = subparts[
                0]["destination"]
            mixedflightinit["flight"][j]["full"][0]["waitingTime"] = subparts[
                0]["waitingTime"]
            mixedflightinit["flight"][j]["full"][0]["arrival"] = subparts[0][
                "arrival"]
            mixedflightinit["flight"][j]["full"][0]["arrivalDate"] = subparts[
                0]["arrivalDate"]
            mixedflightinit["flight"][j]["full"][0][
                "arrivalDay"] = models.getdayabbrevationfromdatestr(
                    subparts[0]["arrivalDate"], 0)
            mixedflightinit["flight"][j]["full"][0][
                "departureDay"] = models.getdayabbrevationfromdatestr(
                    flightpart["departureDate"], 0)

    mixedflightinit["flight"] = [
        x for x in mixedflightinit["flight"] if len(x["parts"]) == 2
    ]
    logger.debug("[FlightApi.mixAndMatchInit]-[END]")
    return mixedflightinit
Beispiel #5
0
def mixandmatch(directflight, othermodesinit, othermodesend, logger):

    logger.debug("[START] Flight mix & match")
    directflight = miscUtility.limitResults(directflight, "flight")

    for j in range(len(directflight["flight"])):
        flightpart = directflight["flight"][j]["parts"][0]
        subparts = []
        for k in range(len(othermodesinit)):
            subpart = othermodesinit[k]["parts"][0]
            if dateTimeUtility.isjourneypossible(
                    subpart["arrival"],
                    dateTimeUtility.convertflighttime(flightpart["departure"]),
                    subpart["arrivalDate"], flightpart["departureDate"], 3,
                    24):
                subpart["waitingTime"] = dateTimeUtility.getWaitingTime(
                    subpart["arrival"], flightpart["departure"],
                    subpart["arrivalDate"], flightpart["departureDate"])
                subpart["subJourneyTime"] = dateTimeUtility.gettotalduration(
                    dateTimeUtility.convertflighttime(flightpart["departure"]),
                    subpart["departure"], flightpart["departureDate"],
                    subpart["departureDate"])
                subparts.append(copy.deepcopy(subpart))
        subparts.sort(miscUtility.sortonsubjourneytime)
        if len(subparts) > 5:
            subparts = subparts[0:5]
        continuefurther = 0

        if subparts:
            continuefurther = 1
            minmax1 = minMaxUtil.getMinMaxValues(subparts)
            price1 = int(minMaxUtil.getprice(subparts[0]))
            subJourneyTime1 = subparts[0]["subJourneyTime"]
            waitingtime1 = subparts[0]["waitingTime"]
            departuredate1 = subparts[0]["departureDate"]
            departure1 = subparts[0]["departure"]
            source = subparts[0]["source"]
            newpart = {
                "subParts": subparts,
                "mode": subparts[0]["mode"],
                "id": directflight["flight"][j]["full"][0]["id"] + str(0),
                "destination": subparts[0]["destination"],
                "source": subparts[0]["source"],
                "carrierName": subparts[0]["carrierName"]
            }
            flightpart[
                "id"] = directflight["flight"][j]["full"][0]["id"] + str(1)
            directflight["flight"][j]["parts"].insert(0, newpart)
            directflight["flight"][j]["full"][0]["route"] = newpart[
                "source"] + "," + newpart["mode"] + "," + newpart[
                    "destination"] + ",flight," + flightpart["destination"]

        subparts = []
        for k in range(len(othermodesend)):
            subpart = othermodesend[k]["parts"][0]
            if dateTimeUtility.isjourneypossible(
                    dateTimeUtility.convertflighttime(flightpart["arrival"]),
                    subpart["departure"], flightpart["arrivalDate"],
                    subpart["departureDate"], 3, 24):
                subpart["waitingTime"] = dateTimeUtility.getWaitingTime(
                    flightpart["arrival"], subpart["departure"],
                    flightpart["arrivalDate"], subpart["departureDate"])
                subpart["subJourneyTime"] = dateTimeUtility.gettotalduration(
                    subpart["arrival"],
                    dateTimeUtility.convertflighttime(flightpart["arrival"]),
                    subpart["arrivalDate"], flightpart["arrivalDate"])
                subparts.append(copy.deepcopy(subpart))
        subparts.sort(miscUtility.sortonsubjourneytime)
        if len(subparts) > 5:
            subparts = subparts[0:5]

        if subparts and continuefurther == 1:
            minmax2 = minMaxUtil.getMinMaxValues(subparts)
            price2 = int(minMaxUtil.getprice(subparts[0]))
            destination = subparts[0]["destination"]
            subJourneyTime2 = subparts[0]["subJourneyTime"]
            newpart = {
                "subParts": subparts,
                "mode": subparts[0]["mode"],
                "id": directflight["flight"][j]["full"][0]["id"] + str(2),
                "destination": subparts[0]["destination"],
                "source": subparts[0]["source"],
                "carrierName": subparts[0]["carrierName"]
            }
            directflight["flight"][j]["parts"].append(newpart)
            directflight["flight"][j]["full"][0]["route"] = directflight[
                "flight"][j]["full"][0]["route"] + "," + subparts[0][
                    "mode"] + "," + newpart["destination"]
            directflight["flight"][j]["full"][0]["price"] = int(
                directflight["flight"][j]["full"][0]
                ["price"]) + price1 + price2
            directflight["flight"][j]["full"][0]["minPrice"] = int(
                directflight["flight"][j]["full"][0]["minPrice"]) + int(
                    minmax1["minPrice"]) + int(minmax2["minPrice"])
            directflight["flight"][j]["full"][0]["maxPrice"] = int(
                directflight["flight"][j]["full"][0]["maxPrice"]) + int(
                    minmax1["maxPrice"]) + int(minmax2["maxPrice"])
            directflight["flight"][j]["full"][0][
                "duration"] = dateTimeUtility.addDurations(
                    dateTimeUtility.addDurations(
                        directflight["flight"][j]["full"][0]["duration"],
                        subJourneyTime1), subJourneyTime2)
            directflight["flight"][j]["full"][0][
                "minDuration"] = dateTimeUtility.addDurations(
                    dateTimeUtility.addDurations(
                        directflight["flight"][j]["full"][0]["minDuration"],
                        minmax1["minDuration"]), minmax2["minDuration"])
            directflight["flight"][j]["full"][0][
                "maxDuration"] = dateTimeUtility.addDurations(
                    dateTimeUtility.addDurations(
                        directflight["flight"][j]["full"][0]["maxDuration"],
                        minmax1["maxDuration"]), minmax2["maxDuration"])
            directflight["flight"][j]["full"][0]["minDeparture"] = minmax1[
                "minDep"]
            directflight["flight"][j]["full"][0]["maxDeparture"] = minmax1[
                "maxDep"]
            directflight["flight"][j]["full"][0]["minArrival"] = minmax2[
                "minArr"]
            directflight["flight"][j]["full"][0]["maxArrival"] = minmax2[
                "maxArr"]
            directflight["flight"][j]["full"][0]["destination"] = destination
            directflight["flight"][j]["full"][0]["source"] = source
            directflight["flight"][j]["full"][0][
                "waitingTime"] = dateTimeUtility.addDurations(
                    waitingtime1, subparts[0]["waitingTime"])
            directflight["flight"][j]["full"][0]["arrival"] = subparts[0][
                "arrival"]
            directflight["flight"][j]["full"][0]["departure"] = departure1
            directflight["flight"][j]["full"][0]["arrivalDate"] = subparts[0][
                "arrivalDate"]
            directflight["flight"][j]["full"][0][
                "departureDate"] = departuredate1
            directflight["flight"][j]["full"][0][
                "arrivalDay"] = models.getdayabbrevationfromdatestr(
                    subparts[0]["arrivalDate"], 0)
            directflight["flight"][j]["full"][0][
                "departureDay"] = models.getdayabbrevationfromdatestr(
                    departuredate1, 0)

    directflight["flight"] = [
        x for x in directflight["flight"] if len(x["parts"]) == 3
    ]
    logger.debug("[END] flight mix & match")
    return directflight
Beispiel #6
0
    def getresults(self, sourcecity, destinationcity, journeydate, trainclass, flightclass, numberofadults):

        logger.debug("[START]-Get Results From FlightApi for Source:[%s] and Destination:[%s],JourneyDate:[%s] ",sourcecity,destinationcity,journeydate)
        with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:

            source = TravelPlanner.startuputil.gettraincity(sourcecity).title()
            destination = TravelPlanner.startuputil.gettraincity(destinationcity).title()
            # get nearest airport and nearest big airport to our source city
            url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + source
            url = url.replace(' ', '%20')
            response = urllib2.urlopen(url)
            sourcelatlong = json.loads(response.read())
            response.close()
            sourcelat = sourcelatlong["results"][0]["geometry"]["location"]["lat"]
            sourcelong = sourcelatlong["results"][0]["geometry"]["location"]["lng"]
            sourceairport = distanceutil.findnearestairport(sourcelat,sourcelong)
            bigsourceairport = distanceutil.findnearestbigairport(sourcelat,sourcelong)

            # get nearest airport and nearest big airport to our destination city
            url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + destination
            url = url.replace(' ', '%20')
            response2 = urllib2.urlopen(url)
            destlatlong = json.loads(response2.read())
            destlat = destlatlong["results"][0]["geometry"]["location"]["lat"]
            destlong = destlatlong["results"][0]["geometry"]["location"]["lng"]
            destairport = distanceutil.findnearestairport(destlat, destlong)
            bigdestinationairport = distanceutil.findnearestbigairport(destlat, destlong)
            
            bigsource = flightutil.stationtocitymap[bigsourceairport]
            bigdestination = flightutil.stationtocitymap[bigdestinationairport]
            sourceflight = flightutil.stationtocitymap[sourceairport]
            destinationflight = flightutil.stationtocitymap[destairport]

            if source != sourceflight:
                othermodessminitfuture = executor.submit(self.getothermodes,sourcecity, sourceflight, journeydate,trainclass,numberofadults)
                othermodessminit2future = executor.submit(self.getothermodes, sourcecity, sourceflight, dateTimeUtility.getPreviousDate(journeydate),trainclass,numberofadults)
            if destination != destinationflight:
                othermodessmendfuture = executor.submit(self.getothermodes, destinationflight, destinationcity, journeydate,trainclass,numberofadults)
                othermodessmend2future = executor.submit(self.getothermodes, destinationflight, destinationcity, dateTimeUtility.getNextDate(journeydate),trainclass,numberofadults)

            onlyflightfuture = executor.submit(flightSkyScanner.getApiResults,sourceflight,destinationflight,journeydate,"flight0",flightclass,numberofadults)

            finallist = {}
            if (bigsource != 'empty') and (bigdestination != 'empty') and (bigsource != destinationflight) and (bigdestination != sourceflight):
                mixedflight = {"flight": []}
                mixedflightend = {"flight": []}
                mixedflightinit = {"flight": []}
                othermodesinit=[]
                othermodesend=[]
                othermodesinitfuture = []
                othermodesendfuture = []

                # if there is only one big airport in between or both source and destination are big airports
                if (bigsource != bigdestination) and ((bigsource != sourceflight) and (bigdestination != destinationflight)):
                    mixedflightfuture = executor.submit(flightSkyScanner.getApiResults,bigsource,bigdestination,journeydate,"flight1",flightclass,numberofadults)
                    othermodesinitfuture = executor.submit(self.getothermodes, sourcecity, bigsource, journeydate,trainclass,numberofadults)
                    othermodesinit2future = executor.submit(self.getothermodes, sourcecity, bigsource, dateTimeUtility.getPreviousDate(journeydate),trainclass,numberofadults)
                    othermodesendfuture = executor.submit(self.getothermodes, bigdestination, destinationcity, journeydate,trainclass,numberofadults)
                    othermodesend2future = executor.submit(self.getothermodes, bigdestination, destinationcity, dateTimeUtility.getNextDate(journeydate),trainclass,numberofadults)

                if bigsource != sourceflight:
                    mixedflightendfuture = executor.submit(flightSkyScanner.getApiResults, bigsource, destinationflight, journeydate, "flight2", flightclass, numberofadults)
                    if not othermodesinitfuture:
                        othermodesinitfuture = executor.submit(self.getothermodes,sourcecity, bigsource, journeydate, trainclass,numberofadults)
                        othermodesinit2future = executor.submit(self.getothermodes, sourcecity, bigsource, dateTimeUtility.getPreviousDate(journeydate), trainclass, numberofadults)

                if bigdestination != destinationflight:
                    mixedflightinitfuture = executor.submit(flightSkyScanner.getApiResults,sourceflight,bigdestination,journeydate,"flight3",flightclass,numberofadults)
                    if not othermodesendfuture:
                        othermodesendfuture = executor.submit(self.getothermodes, bigdestination, destinationcity, journeydate,trainclass,numberofadults)
                        othermodesend2future = executor.submit(self.getothermodes, bigdestination, destinationcity, dateTimeUtility.getNextDate(journeydate),trainclass,numberofadults)

                onlyflight = onlyflightfuture.result()
                onlyflight = miscUtility.limitResults(onlyflight, "flight")
                if source != sourceflight and destination != destinationflight:
                    othermodessminit = othermodessminitfuture.result()
                    othermodessminit2 = othermodessminit2future.result()
                    othermodessmend = othermodessmendfuture.result()
                    othermodessmend2 = othermodessmend2future.result()
                    onlyflight = self.mixandmatch(onlyflight, othermodessminit,othermodessminit2, othermodessmend, othermodessmend2)
                elif source != sourceflight:
                    othermodessminit = othermodessminitfuture.result()
                    othermodessminit2 = othermodessminit2future.result()
                    onlyflight = self.mixAndMatchEnd(onlyflight, othermodessminit, othermodessminit2)
                elif destination != destinationflight:
                    othermodessmend = othermodessmendfuture.result()
                    othermodessmend2 = othermodessmend2future.result()
                    onlyflight = self.mixAndMatchInit(onlyflight, othermodessmend, othermodessmend2)

                if (bigsource != bigdestination) and ((bigsource != sourceflight) and (bigdestination != destinationflight)):
                    othermodesinit = othermodesinitfuture.result()
                    othermodesinit2 = othermodesinit2future.result()
                    othermodesend = othermodesendfuture.result()
                    othermodesend2 = othermodesend2future.result()
                    mixedflight = self.mixandmatch(mixedflightfuture.result(), othermodesinit,othermodesinit2, othermodesend,othermodesend2)

                if bigsource != sourceflight:
                    if not othermodesinit:
                        othermodesinit = othermodesinitfuture.result()
                        othermodesinit2 = othermodesinit2future.result()
                    if destination != destinationflight:
                        mixedflightend = self.mixandmatch(mixedflightendfuture.result(), othermodesinit, othermodesinit2, othermodessmend, othermodessmend2)
                    else:
                        mixedflightend = self.mixAndMatchEnd(mixedflightendfuture.result(), othermodesinit, othermodesinit2)

                if bigdestination != destinationflight:
                    if not othermodesend:
                        othermodesend = othermodesendfuture.result()
                        othermodesend2 = othermodesend2future.result()
                    if source != sourceflight:
                        mixedflightinit = self.mixandmatch(mixedflightinitfuture.result(), othermodessminit, othermodessminit2, othermodesend, othermodesend2)
                    else:
                        mixedflightinit = self.mixAndMatchInit(mixedflightinitfuture.result(), othermodesend,othermodesend2)

                finallist["flight"]=onlyflight["flight"]+mixedflight["flight"]+mixedflightinit["flight"]+mixedflightend["flight"]
            else:
                onlyflight = onlyflightfuture.result()
                onlyflight = miscUtility.limitResults(onlyflight, "flight")
                if source != sourceflight and destination != destinationflight:
                    othermodessminit = othermodessminitfuture.result()
                    othermodessminit2 = othermodessminit2future.result()
                    othermodessmend = othermodessmendfuture.result()
                    othermodessmend2 = othermodessmend2future.result()
                    onlyflight = self.mixandmatch(onlyflight, othermodessminit, othermodessminit2, othermodessmend, othermodessmend2)
                elif source != sourceflight:
                    othermodessminit = othermodessminitfuture.result()
                    othermodessminit2 = othermodessminit2future.result()
                    onlyflight = self.mixAndMatchEnd(onlyflight, othermodessminit, othermodessminit2)
                elif destination != destinationflight:
                    othermodessmend = othermodessmendfuture.result()
                    othermodessmend2 = othermodessmend2future.result()
                    onlyflight = self.mixAndMatchInit(onlyflight, othermodessmend, othermodessmend2)

                finallist["flight"] = onlyflight["flight"]
            logger.debug("[END]-Get Results From FlightApi for Source:[%s] and Destination:[%s],JourneyDate:[%s] ", sourcecity, destinationcity, journeydate)
            return finallist