Modified sorting logic of build list

This commit is contained in:
mkuba50 2017-12-13 18:03:52 +01:00
parent 89abdc8136
commit dd47de1172
2 changed files with 19 additions and 14 deletions

View File

@ -26,7 +26,7 @@ function uupListIds() {
$files = preg_grep('/\.json$/', $files); $files = preg_grep('/\.json$/', $files);
consoleLogger('Parsing database info...'); consoleLogger('Parsing database info...');
$database = @file_get_contents('cache/fileinfo.json'); $database = @file_get_contents('cache/fileinfo.json');
$database = json_decode($database, true); $database = json_decode($database, true);
if(empty($database)) $database = array(); if(empty($database)) $database = array();
@ -51,13 +51,13 @@ function uupListIds() {
'arch' => $arch, 'arch' => $arch,
); );
$newDb = array_merge($newDb, array($uuid => $temp)); $newDb[$uuid] = $temp;
} else { } else {
$title = $database[$uuid]['title']; $title = $database[$uuid]['title'];
$build = $database[$uuid]['build']; $build = $database[$uuid]['build'];
$arch = $database[$uuid]['arch']; $arch = $database[$uuid]['arch'];
$newDb = array_merge($newDb, array($uuid => $database[$uuid])); $newDb[$uuid] = $database[$uuid];
} }
$temp = array( $temp = array(
@ -67,21 +67,26 @@ function uupListIds() {
'uuid' => $uuid, 'uuid' => $uuid,
); );
$builds = array_merge( $tmp = explode('.', $build);
$builds, $tmp[0] = str_pad($tmp[0], 10, '0', STR_PAD_LEFT);
array($build.$arch.$title.$uuid => $temp) $tmp[1] = str_pad($tmp[1], 10, '0', STR_PAD_LEFT);
); $tmp = $tmp[0].$tmp[1];
$buildAssoc[$tmp][] = $arch.$title.$uuid;
$builds[$tmp.$arch.$title.$uuid] = $temp;
} }
krsort($builds); krsort($buildAssoc);
$buildsNew = array(); $buildsNew = array();
foreach($builds as $val) {
$buildsNew = array_merge($buildsNew, array($val)); foreach($buildAssoc as $key => $val) {
sort($val);
foreach($val as $id) {
$buildsNew[] = $builds[$key.$id];
}
} }
$builds = $buildsNew; $builds = $buildsNew;
consoleLogger('Done parsing database info.'); consoleLogger('Done parsing database info.');
if($newDb != $database) { if($newDb != $database) {

View File

@ -16,7 +16,7 @@ limitations under the License.
*/ */
function uupApiVersion() { function uupApiVersion() {
return '1.6.2'; return '1.6.3';
} }
function uupApiPrintBrand() { function uupApiPrintBrand() {