Skip to content

Commit

Permalink
Add some search capabilities + coordinates search with mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
eprochasson committed Jul 21, 2013
1 parent b1e04e2 commit 2f598f1
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 15 deletions.
11 changes: 5 additions & 6 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@

Browse/search users
User geolocalisation.

Make sure logout users are redirected to the front page, always.

Check user security: do not allow user to change all their profile.
Check filepicker secret/security thingy. Not sure it's cool.


Setting page

Thing needs serious design work. Finish notification template (for single notification)
Complete Lexicon...

Subscription process + email validation.

Check input security (not too long, invalid characters, injection...).
Fix Bug in Profile page.

Find a way to factorize some client code.
Find a way to factorize some client code.

Still have some presence with empty users!!!
4 changes: 4 additions & 0 deletions client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@ Meteor.startup(function(){
}, Activities.activitiesPerPage);
});

Deps.autorun(function(){
searchHandle = Meteor.subscribe("searchResults", Session.get("searchQuery", Meteor.user.searchResultsLimit));
});

// Meteor.subscribe('adminShowEveryone');
});
11 changes: 11 additions & 0 deletions lib/collections/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//User collection defined by default

Meteor.users.allow({
update: function(){ return false ;},
remove: function(){ return false ;},
insert: function(){ return false ;}
});

if(Meteor.isServer){
Meteor.users._ensureIndex({'loc':"2d"});
}
32 changes: 32 additions & 0 deletions server/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,40 @@ if(Questions.find().count() == 0){
"validation": {},
"value": ""
});
}


if(Meteor.users.find({}).count() <= 2){
var gender = "F";
for(var i = 1 ; i < 10 ; i++){
gender = (i % 2) ? "F" : "M";
Meteor.users.insert({
"createdAt": 1372216131137,
"emails": [
{
"address": "user"+i+"@test.com",
"verified": false
}
],
"lastseen": 1473524657763,
"online": 1,
"profile": {
"dob": "08-11-1982",
"gender": gender,
"name": "Fake User"+i
},
"services": {
},
"settings": {
"invisible": false
},
"visible": 1,
"profile_complete": 1,
"loc": [22.2861678+Math.random(),114.1425153+Math.random()]
});
}
}

//if(Meteor.users.find({}).count() <= 4){
//// Meteor.users.insert({
//// "createdAt": 1372216131137,
Expand Down
30 changes: 30 additions & 0 deletions server/publications.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,36 @@ Meteor.publish('oneUserActivities', function(userId, limit){
}
});

Meteor.publish('searchResults', function(options,limit){
if(!options||!this.userId){
return false;
}

var user = Meteor.users.findOne(this.userId);
var userloc = user.loc;
var friends = Friends.find({me: this.userId});
var friendlist = [];
friends.forEach(function(f){
friendlist.push(f.target);
});

options._id = {$nin: friendlist};
if(userloc){
options.loc = {
$near: {
$geometry: {
type: 'Point',
coordinates: userloc
}
}
};
}

options.visible = 1;
return Meteor.users.find(options, {sort: {lastseen: -1}, limit: limit, fields: Meteor.users.publicProfileInformation});
});




/******************************
Expand Down
21 changes: 12 additions & 9 deletions server/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,21 @@ Meteor.methods({
if(!valid){
throw new Meteor.Error(400, 'Invalid Data');
} else {
// Account only visible if at least those two information are made available.
var visible = 0;
if(cleaned.name && cleaned.gender){
visible = 1;
}

Meteor.users.update(Meteor.userId(), {
var change = {
$set: {
profile : cleaned,
visible: visible
profile : cleaned
}
});
};
// Update location if specify, set mongo 2d coordinates.
if(cleaned && cleaned.location){
var loc = cleaned.location.split(',');
change.$set.loc = [parseFloat(loc[0]), parseFloat(loc[1])]
}

Meteor.users.update(Meteor.userId(), change);



Activities.insertActivity({
type: 'update_profile',
Expand Down
Empty file removed test/unit/client/message.js
Empty file.

0 comments on commit 2f598f1

Please sign in to comment.