add weight delta to stat
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		
							parent
							
								
									09fe5f2324
								
							
						
					
					
						commit
						ddca8c456f
					
				@ -239,16 +239,27 @@ func (db *DB) GetStatBetween(chatID int64, startTime time.Time, endTime time.Tim
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	firstWeight := 0.0
 | 
			
		||||
	lastWeight := 0.0
 | 
			
		||||
	countWeights := 0
 | 
			
		||||
	for weightCursor.Next(context.Background()) {
 | 
			
		||||
		var result Weight
 | 
			
		||||
		if err := weightCursor.Decode(&result); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		res["Вес кг"] = result.Weight
 | 
			
		||||
		if firstWeight == 0 {
 | 
			
		||||
			firstWeight = result.Weight
 | 
			
		||||
		}
 | 
			
		||||
		lastWeight = result.Weight
 | 
			
		||||
		countWeights++
 | 
			
		||||
	}
 | 
			
		||||
	if err := weightCursor.Err(); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	if countWeights > 0 {
 | 
			
		||||
		res["Изменение веса"] = lastWeight - firstWeight
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return res, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user