fix challenge ordering

Now challenges are ordered on map first by top order value of json file
second by index of array
This commit is contained in:
Berkeley Martinez
2015-08-10 23:29:32 -07:00
parent 43e3dc8914
commit 5f21db457d
3 changed files with 9 additions and 2 deletions

View File

@ -22,6 +22,9 @@
"order": { "order": {
"type": "number" "type": "number"
}, },
"suborder": {
"type": "number"
},
"dashedName": { "dashedName": {
"type": "string" "type": "string"
}, },

View File

@ -63,7 +63,8 @@ Challenge.destroyAll(function(err, info) {
.toLowerCase() .toLowerCase()
.replace(/\:/g, '') .replace(/\:/g, '')
.replace(/\s/g, '-'); .replace(/\s/g, '-');
challenge.order = +('' + order + (index + 1)); challenge.order = order;
challenge.suborder = index + 1;
challenge.block = block; challenge.block = block;
return challenge; return challenge;

View File

@ -458,7 +458,10 @@ module.exports = function(app) {
.map(camperCount => numberWithCommas(camperCount)); .map(camperCount => numberWithCommas(camperCount));
const query = { const query = {
order: 'order ASC' order: [
'order ASC',
'suborder ASC'
]
}; };
// create a stream of all the challenges // create a stream of all the challenges