mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-04 01:56:33 +02:00 
			
		
		
		
	parseTrip: handle stopL[] items without idx 🐛
This commit is contained in:
		
							parent
							
								
									11ca3b171a
								
							
						
					
					
						commit
						92fb29d687
					
				
					 1 changed files with 3 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -2,6 +2,7 @@
 | 
			
		|||
 | 
			
		||||
const minBy = require('lodash/minBy')
 | 
			
		||||
const maxBy = require('lodash/maxBy')
 | 
			
		||||
const last = require('lodash/last')
 | 
			
		||||
 | 
			
		||||
const parseTrip = (ctx, t) => { // t = raw trip
 | 
			
		||||
	const {profile} = ctx
 | 
			
		||||
| 
						 | 
				
			
			@ -9,8 +10,8 @@ const parseTrip = (ctx, t) => { // t = raw trip
 | 
			
		|||
	// pretend the trip is a leg in a journey
 | 
			
		||||
	const fakeLeg = {
 | 
			
		||||
		type: 'JNY',
 | 
			
		||||
		dep: minBy(t.stopL, 'idx'),
 | 
			
		||||
		arr: maxBy(t.stopL, 'idx'),
 | 
			
		||||
		dep: minBy(t.stopL, 'idx') || t.stopL[0],
 | 
			
		||||
		arr: maxBy(t.stopL, 'idx') || last(t.stopL),
 | 
			
		||||
		jny: t,
 | 
			
		||||
	}
 | 
			
		||||
	const trip = profile.parseJourneyLeg(ctx, fakeLeg, t.date)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue