Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

people slugs

  • Loading branch information...
commit 018c8b2aa7f075a7e189484ab65b9eae2998d3e2 1 parent 40aa082
@dshaw dshaw authored visnup committed
View
1  controllers/teams.coffee
@@ -16,6 +16,7 @@ app.get /^\/teams(\/pending)?\/?$/, (req, res, next) ->
ids = _.reduce teams, ((r, t) -> r.concat(t.peopleIds)), []
only =
email: 1
+ slug: 1
name: 1
location: 1
imageURL: 1
View
17 migrations/slug-people.js
@@ -1,22 +1,19 @@
var slugs = {};
-var dupes = [];
+var dupes = {};
db.people.find({ $or : [ { 'twit.screenName' : { $exists : true } } , { 'github.login' : { $exists : true } } ] },
{'name': 1, 'twit.screenName': 1, 'github.login': 1}).forEach(function(p) {
var slug = ((p.twit && p.twit.screenName) || (p.github && p.github.login)).toLowerCase();
if (slugs[slug]) {
- print(slug);
- dupes.push({'_id':p._id, slug: slug});
+ slugs[slug].push(p._id);
+ dupes[slug] = slugs[slug];
slug = p._id;
} else {
- slugs[slug] = 1;
+ slugs[slug] = [p._id];
+ db.people.update({_id: p._id}, {$set: {slug: slug}});
+ print(slug, '<-', p.name);
}
- print(slug, '<-', p.name);
- db.people.update({_id: p._id}, {$set: {slug: slug}});
});
print('--- dupes ---');
-
-dupes.forEach(function (dupe) {
- print(dupe._id, ':', dupe.slug);
-});
+printjson(dupes);
View
8 models/person.coffee
@@ -16,7 +16,9 @@ PersonSchema = module.exports = new mongoose.Schema
admin: Boolean
role: { type: String, enum: ROLES }
technical: Boolean
- slug: String
+ slug:
+ type: String
+ index: true
PersonSchema.plugin require('mongoose-types').useTimestamps
PersonSchema.plugin auth,
everymodule:
@@ -146,7 +148,7 @@ PersonSchema.method 'updateWithGithub', (ghUser, token, callback) ->
Person.createWithGithub.call
create: (params, callback) =>
_.extend this, params
- @slug = @github.login
+ @slug = @github.login.toLowerCase()
@company ||= @github.company
@location ||= @github.location
@save callback
@@ -157,7 +159,7 @@ PersonSchema.method 'updateWithTwitter', (twitter, token, secret, callback) ->
create: (params, callback) =>
_.extend this, params
@twitterScreenName = @twit.screenName
- @slug = @twit.screenName
+ @slug = @twitterScreenName.toLowerCase()
@name ||= @twit.name
@location ||= @twit.location
@bio ||= @twit.description
View
4 views/teams/index.jade
@@ -14,12 +14,12 @@ ul.teams
li.invites (#{team.invites.length} invited)
- each m in members
- if (m)
- li: a( href: '/people/' + m.id )
+ li: a( href: '/people/' + m )
img.avatar( src: avatar_url(m), title: m.login )
ul.members
- each m in members
- if (m)
- li: a( href: '/people/' + m.id)= m.login
+ li: a( href: '/people/' + m )= m.login
.location= locations(members)
.description!= markdown(team.description)
- q = req.query
Please sign in to comment.
Something went wrong with that request. Please try again.