Skip to content

Commit

Permalink
feat(sort): popularity
Browse files Browse the repository at this point in the history
  • Loading branch information
bboure committed Jul 10, 2020
1 parent cee0da3 commit f494c6a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports.view = {
boundary_rect: require('./view/boundary_rect'),
boundary_country: require('./view/boundary_country'),
sort_distance: require('./view/sort_distance'),
sort_popularity: require('./view/sort_popularity'),
sources: require('./view/sources'),
layers: require('./view/layers'),
boundary_gid: require('./view/boundary_gid')
Expand Down
3 changes: 2 additions & 1 deletion view/sort_distance.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
module.exports = function( vs ){

// validate required params
if( !vs.isset('focus:point:lat') ||
if( vs.var('sort:field').get() !== 'distance' ||
!vs.isset('focus:point:lat') ||
!vs.isset('focus:point:lon') ||
!vs.isset('sort:distance:order') ||
!vs.isset('sort:distance:distance_type') ||
Expand Down
15 changes: 15 additions & 0 deletions view/sort_popularity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

module.exports = function( vs ){
if ( !vs.isset('sort:field') ||
vs.var('sort:field').get() !== 'popularity' ) {
return null;
}
// base view
var view = {
popularity: {
order: 'desc',
}
};

return view;
};

0 comments on commit f494c6a

Please sign in to comment.