Merge pull request #4764 from mempool/nymkappa/fix-mysql-query

fix mysql query
This commit is contained in:
wiz 2024-03-11 19:32:27 +09:00 committed by GitHub
commit 93f547e446
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -70,15 +70,26 @@ class AccelerationRepository {
JOIN pools on pools.unique_id = accelerations.pool
`;
let params: any[] = [];
let hasFilter = false;
if (interval) {
query += ` WHERE accelerations.added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() `;
hasFilter = true;
}
if (height != null) {
query += ` WHERE accelerations.height = ? `;
if (hasFilter) {
query += ` AND accelerations.height = ? `;
} else {
query += ` WHERE accelerations.height = ? `;
}
params.push(height);
} else if (poolSlug != null) {
query += ` WHERE pools.slug = ? `;
if (hasFilter) {
query += ` AND pools.slug = ? `;
} else {
query += ` WHERE pools.slug = ? `;
}
params.push(poolSlug);
}