Exemplo n.º 1
0
def get_one_month_data(job_id, from_date):
    job = Job.get_single_job(job_id)
    airports = [job.departureStationId, job.arrivalStationId]
    to_date = timeUtils.add_one_month(from_date)
    flights = Flight.get_flights(airports, airports, from_date, to_date)

    out_flights_dto = []
    in_flights_dto = []

    for flight in flights:
        if ((job.departureAirport.IATA == flight.departureAirport.IATA) and (
                job.arrivalAirport.IATA == flight.arrivalAirport.IATA)):
            out_flights_dto.append(flight)
        elif ((job.departureAirport.IATA == flight.arrivalAirport.IATA) and (
                job.arrivalAirport.IATA == flight.departureAirport.IATA)):
            in_flights_dto.append(flight)
        else:
            print("Error in flight: departure " + flight.departureAirport.IATA
                  + " arrival " + flight.arrivalAirport.IATA)

    flights_dto_response = []
    for outbound in out_flights_dto:
        for inbound in in_flights_dto:
            daysbetween = timeUtils.get_days_between(str(outbound.departureDate), str(inbound.departureDate))
            if (daysbetween > 0) and (daysbetween <= MAXIMUM_FLIGHT_DURATION):
                flights_dto_response.append(FlightDataDto(outbound, inbound).__dict__)

    return flights_dto_response
Exemplo n.º 2
0
def get_jobs_json():
    jobs = Job.get_jobs()
    jobs_dto = []
    for job in jobs:
        jobs_dto.append(JobDto(job).__dict__)
    return json.dumps(jobs_dto)
Exemplo n.º 3
0
def process_job_report(report):
    try:
        print "Job report received for job " + str(report['jobId']) + " from " + report['scrapperName'] + " scrapper with status " + report['status']
        return Job.updateStatus(report)
    except KeyError:
        return "Received incomplete report"
Exemplo n.º 4
0
def undelete(jobId):
    return Job.undelete(jobId)
Exemplo n.º 5
0
def delete(jobId):
    return Job.delete(jobId)
Exemplo n.º 6
0
def deactivate(jobId):
    return Job.deactivate(jobId)
Exemplo n.º 7
0
def activate(jobId):
    return Job.activate(jobId)
Exemplo n.º 8
0
def add(departure_station_iata, arrival_station_iata):
    return Job.add_job(departure_station_iata, arrival_station_iata)