Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Fix the sort list function in couchdb design docs #738

Merged
merged 4 commits into from
Oct 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/utils/pouch-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ function generateSortFunction(sortFunction, includeCompareDate, filterFunction)
generatedFunction += 'rows = rows.filter(' + filterFunction + ');';
}
generatedFunction += 'rows.sort(' + sortFunction + ');' +
'if (req.query.sortDesc) {' +
'rows = rows.reverse();' +
'}' +
'if (req.query.sortStartKey) {' +
'var startKey = JSON.parse(req.query.sortStartKey);' +
'for (var i=0; i<rows.length; i++) {' +
Expand All @@ -99,9 +102,6 @@ function generateSortFunction(sortFunction, includeCompareDate, filterFunction)
'}' +
'}' +
'}' +
'if (req.query.sortDesc) {' +
'rows = rows.reverse();' +
'}' +
'if (req.query.sortLimit) {' +
'rows = rows.slice(startingPosition, parseInt(req.query.sortLimit)+startingPosition);' +
'} else if (startingPosition > 0) {' +
Expand Down Expand Up @@ -241,7 +241,7 @@ let designDocs = [{
}
return includeRow;
}.toString()),
version: 5
version: 6
}, {
name: 'appointments_by_patient',
function: generateView('appointment',
Expand Down Expand Up @@ -283,7 +283,7 @@ let designDocs = [{
}
}
}.toString()),
version: 4
version: 5
}, {
name: 'inventory_by_type',
function: generateView('inventory',
Expand Down Expand Up @@ -351,7 +351,7 @@ let designDocs = [{
name: 'patient_by_display_id',
function: generateView('patient', patientListingKey),
sort: patientListingSearch,
version: 6
version: 7
}, {
name: 'patient_by_status',
function: generateView('patient',
Expand All @@ -366,7 +366,7 @@ let designDocs = [{
'}'
),
sort: patientListingSearch,
version: 3
version: 4
}, {
name: 'photo_by_patient',
function: generateView('photo',
Expand Down