fix mysql query
This commit is contained in:
		
							parent
							
								
									0dff902151
								
							
						
					
					
						commit
						ece40c5e74
					
				@ -70,15 +70,26 @@ class AccelerationRepository {
 | 
				
			|||||||
      JOIN pools on pools.unique_id = accelerations.pool
 | 
					      JOIN pools on pools.unique_id = accelerations.pool
 | 
				
			||||||
    `;
 | 
					    `;
 | 
				
			||||||
    let params: any[] = [];
 | 
					    let params: any[] = [];
 | 
				
			||||||
 | 
					    let hasFilter = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (interval) {
 | 
					    if (interval) {
 | 
				
			||||||
      query += ` WHERE accelerations.added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() `;
 | 
					      query += ` WHERE accelerations.added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() `;
 | 
				
			||||||
 | 
					      hasFilter = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (height != null) {
 | 
					    if (height != null) {
 | 
				
			||||||
      query += ` WHERE accelerations.height = ? `;
 | 
					      if (hasFilter) {
 | 
				
			||||||
 | 
					        query += ` AND accelerations.height = ? `;
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        query += ` WHERE accelerations.height = ? `;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      params.push(height);
 | 
					      params.push(height);
 | 
				
			||||||
    } else if (poolSlug != null) {
 | 
					    } else if (poolSlug != null) {
 | 
				
			||||||
      query += ` WHERE pools.slug = ? `;
 | 
					      if (hasFilter) {
 | 
				
			||||||
 | 
					        query += ` AND pools.slug = ? `;
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        query += ` WHERE pools.slug = ? `;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      params.push(poolSlug);
 | 
					      params.push(poolSlug);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user