Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored part of flighthistory request #2064

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ public interface BookingDetailRepository extends CrudRepository<BookingDetail, L
@Query("SELECT pax FROM Passenger pax " + "left join fetch pax.passengerDetails "
+ "left join fetch pax.bookingDetails "
+ "left join fetch pax.passengerTripDetails "
+ "left join fetch pax.flight "
+ "WHERE pax.id IN ("
+ "left join fetch pax.flight f "
+ "left join fetch f.mutableFlightDetails mf "
+ "WHERE (f.direction = 'O' AND mf.etd > :dateLimit) "
+ "OR (f.direction ='I' AND mf.eta > :dateLimit ) "
+ "OR (f.direction = 'A' AND (mf.etd > :dateLimit "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f.direction of 'C' should be accounted for as well.

+ "OR mf.eta > :dateLimit))"
+ "AND pax.id IN ("
+ "SELECT pxtag.pax_id FROM PassengerIDTag pxtag WHERE pxtag.idTag IN (SELECT p.idTag FROM PassengerIDTag p WHERE p.pax_id = (:pax_id) ))")
List<Passenger> getBookingDetailsByPassengerIdTag(@Param("pax_id") Long pax_id);
List<Passenger> getBookingDetailsByPassengerIdTag(@Param("pax_id") Long pax_id, @Param("dateLimit") Date dateLimit);

@Query("SELECT pax FROM Passenger pax " + "left join fetch pax.passengerDetails "
+ "left join fetch pax.bookingDetails "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import gov.gtas.vo.passenger.PassengerGridItemVo;
import gov.gtas.vo.passenger.FlightPaxVo;
import org.apache.commons.lang3.tuple.Pair;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
Expand Down Expand Up @@ -239,6 +240,7 @@ public List<Flight> getTravelHistoryNotByItinerary(Long paxId, Long pnrId, Strin
@Override
@Transactional
public List<Passenger> getBookingDetailHistoryByPaxID(Long pId) {
DateTime dateLimitForRecall = new DateTime().minusYears(1); //1 year recall limit
List<Passenger> tamrIdMatches;
if (tamrEnabled && tamrResolvePassengerHistory) {
tamrIdMatches = bookingDetailRepository.getBookingDetailsByTamrId(pId);
Expand All @@ -252,7 +254,7 @@ public List<Passenger> getBookingDetailHistoryByPaxID(Long pId) {
// If there are no tamrId matches, this means the tamrId must be
// NULL or Tamr history resolving is disabled. In that case, just
// do normal matching.
return bookingDetailRepository.getBookingDetailsByPassengerIdTag(pId);
return bookingDetailRepository.getBookingDetailsByPassengerIdTag(pId, dateLimitForRecall.toDate());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,13 @@ public static void deleteAndMaskPIIFromHitDetailVo(HitDetailVo hitDetailVo, Pass

public static void populateFlightVoWithFlightDetail(Flight source, FlightVo target) {
try {

target.setFlightNumber(source.getFlightNumber());
target.setCarrier(source.getCarrier());
target.setEtaDate(source.getMutableFlightDetails().getEtaDate());
target.setEtdDate(source.getEtdDate());
target.setOriginCountry(source.getOriginCountry());
target.setOrigin(source.getOrigin());
target.setDestinationCountry(source.getDestinationCountry());
target.setDestination(source.getDestination());
target.setEtd(source.getMutableFlightDetails().getEtd());
target.setEta(source.getMutableFlightDetails().getEta());
target.setFullFlightNumber(source.getFullFlightNumber());
target.setFlightId(source.getId().toString());
target.setIdTag(source.getIdTag());
target.setPassengerCount(source.getFlightPassengerCount().getPassengerCount());
target.setDirection(source.getDirection());
} catch (Exception e) {
logger.error("error populating flight vo", e);
}
Expand Down