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
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)
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"
def undelete(jobId): return Job.undelete(jobId)
def delete(jobId): return Job.delete(jobId)
def deactivate(jobId): return Job.deactivate(jobId)
def activate(jobId): return Job.activate(jobId)
def add(departure_station_iata, arrival_station_iata): return Job.add_job(departure_station_iata, arrival_station_iata)