Commit 9b2dbf25a079fe2ac0b0051d5d1ae33b101659a2
1 parent
1fecb221
Exists in
master
and in
111 other branches
Add limits to the getGranules query
Showing
2 changed files
with
9 additions
and
5 deletions
Show diff stats
js/app/controllers/EpnTapModule.js
... | ... | @@ -350,7 +350,9 @@ Ext.define('amdaDesktop.EpnTapModule', { |
350 | 350 | 'targetName': targetName, |
351 | 351 | 'productTypes': productTypes, |
352 | 352 | 'timeMin': timeMin, |
353 | - 'timeMax': timeMax | |
353 | + 'timeMax': timeMax, | |
354 | + 'top': this.rowsPerPageNf.value, | |
355 | + 'offset': 0 | |
354 | 356 | }, |
355 | 357 | success: this.updateGranules, |
356 | 358 | failure: this.updateGranulesFail, |
... | ... | @@ -370,8 +372,7 @@ Ext.define('amdaDesktop.EpnTapModule', { |
370 | 372 | }, |
371 | 373 | |
372 | 374 | /** |
373 | - Trigerred when a row is clicked in `granulesGrid` table (see `EpnTapUI.createGranulesGrid()`). Do nothing yet, used | |
374 | - for debug purposes only. | |
375 | + Trigerred when a row is clicked in `granulesGrid` table (see `EpnTapUI.createGranulesGrid()`). | |
375 | 376 | */ |
376 | 377 | updateGranulesFail: function(granule) { |
377 | 378 | var reason = response.status === 200 ? response.responseText : response.statusText; | ... | ... |
php/epntap.php
... | ... | @@ -98,10 +98,13 @@ function getGranules() { |
98 | 98 | $productTypes = filter_var($_GET['productTypes'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); |
99 | 99 | $timeMin = filter_var($_GET['timeMin'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); |
100 | 100 | $timeMax = filter_var($_GET['timeMax'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); |
101 | + $top = filter_var($_GET['top'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | |
102 | + $offset = filter_var($_GET['offset'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | |
101 | 103 | |
102 | - // TODO: make this more beatiful | |
103 | 104 | // TODO find a way to handle 'non existing key errors' (and then add access_format) |
104 | - $query = "SELECT dataproduct_type, target_name, time_min, time_max, granule_uid, access_estsize, access_url, thumbnail_url FROM $tableName" . createFilter($targetName, $productTypes, $timeMin, $timeMax); | |
105 | + $columns = "dataproduct_type, target_name, time_min, time_max, granule_uid, access_estsize, access_url, thumbnail_url"; | |
106 | + $filter = createFilter($targetName, $productTypes, $timeMin, $timeMax); | |
107 | + $query = "SELECT TOP $top $columns FROM $tableName $filter OFFSET $offset"; | |
105 | 108 | $result = request($url, $query); |
106 | 109 | return $result; |
107 | 110 | } | ... | ... |