mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-01 00:26:31 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			652 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			652 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import minBy from 'lodash/minBy.js';
 | |
| import maxBy from 'lodash/maxBy.js';
 | |
| import last from 'lodash/last.js';
 | |
| 
 | |
| const parseTrip = (ctx, t) => { // t = raw trip
 | |
| 	const {profile, opt} = ctx;
 | |
| 
 | |
| 	// pretend the trip is a leg in a journey
 | |
| 	const fakeLeg = {
 | |
| 		type: 'JNY',
 | |
| 		dep: Array.isArray(t.stopL)
 | |
| 			? minBy(t.stopL, 'idx') || t.stopL[0]
 | |
| 			: {},
 | |
| 		arr: Array.isArray(t.stopL)
 | |
| 			? maxBy(t.stopL, 'idx') || last(t.stopL)
 | |
| 			: {},
 | |
| 		jny: t,
 | |
| 	};
 | |
| 
 | |
| 	const trip = profile.parseJourneyLeg(ctx, fakeLeg);
 | |
| 	trip.id = trip.tripId; //TODO journeyId
 | |
| 	delete trip.tripId;
 | |
| 	delete trip.reachable;
 | |
| 
 | |
| 	// TODO opt.scheduledDays
 | |
| 	return trip;
 | |
| };
 | |
| 
 | |
| export {
 | |
| 	parseTrip,
 | |
| };
 |