@dhyasama/totem-models 6.21.2 → 6.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.npmignore ADDED
@@ -0,0 +1,14 @@
1
+ lib-cov
2
+ *.seed
3
+ *.log
4
+ *.csv
5
+ *.dat
6
+ *.out
7
+ *.pid
8
+ *.gz
9
+
10
+ npm-debug.log
11
+ node_modules
12
+
13
+ .DS_Store
14
+ .idea
package/lib/Note.js CHANGED
@@ -44,6 +44,10 @@ module.exports = function(mongoose, config) {
44
44
 
45
45
  };
46
46
 
47
+ // Note.statics.getByCreator = function(personId, cb) {
48
+ // this.find({ 'createdBy': personId }).exec(cb);
49
+ // };
50
+
47
51
  Note.statics.getById = function(id, cb) {
48
52
  this.findOne({
49
53
  '_id': id,
@@ -922,7 +922,7 @@ module.exports = function(mongoose, config) {
922
922
 
923
923
  Organization.methods.merge = function(id) {
924
924
  if (this.merged.indexOf(id) == -1) {
925
- this.merged.push(id);
925
+ this.merged = this.merged.concat([id]);
926
926
  return true;
927
927
  }
928
928
  else {
@@ -1306,48 +1306,33 @@ module.exports = function(mongoose, config) {
1306
1306
  var getUsername = function getUsername(val) {
1307
1307
 
1308
1308
  var URL = require('url');
1309
- var result = URL.parse(val);
1309
+ var parsedUrl = URL.parse(val);
1310
+ var protocol = parsedUrl.protocol;
1310
1311
 
1311
- result = result.pathname;
1312
+ if (!protocol) { parsedUrl = URL.parse('http://' + val); }
1312
1313
 
1313
- if (result.indexOf('/') === 0) { result = result.replace('/', ''); }
1314
- if (result.indexOf('in/') === 0) { result = result.replace('in/', ''); }
1315
- if (result.indexOf('organization/') === 0) { result = result.replace('organization/', ''); }
1316
- if (result.indexOf('/') >= 0) { result = result.split('/')[0]; }
1314
+ var pathname = parsedUrl.pathname;
1317
1315
 
1318
- console.log(val, '-->', result);
1316
+ if (pathname.indexOf('/') === 0) { pathname = pathname.replace('/', ''); }
1317
+ if (pathname.indexOf('company/') === 0) { pathname = pathname.replace('company/', ''); }
1318
+ if (pathname.indexOf('organization/') === 0) { pathname = pathname.replace('organization/', ''); }
1319
+ if (pathname.indexOf('/') >= 0) { pathname = pathname.split('/')[0]; }
1319
1320
 
1320
- return result;
1321
+ console.log('Username:', val, '-->', pathname);
1321
1322
 
1322
- };
1323
+ return pathname;
1323
1324
 
1324
- var domains = {
1325
- facebook: 'https://facebook.com',
1326
- linkedin: 'https://linkedin.com/company',
1327
- twitter: 'https://twitter.com',
1328
- crunchbase: 'https://crunchbase.com/organization'
1329
1325
  };
1330
1326
 
1331
1327
  var username = getUsername(value);
1332
1328
 
1333
- // todo - tests
1334
- // getUsername('dhyasama');
1335
- // getUsername('in/dhyasama');
1336
- // getUsername('http://facebook.com/dhyasama');
1337
- // getUsername('http://linkedin.com/in/dhyasama');
1338
- // getUsername('https://twitter.com/dhyasama');
1339
- // getUsername('http://www.facebook.com/dhyasama');
1340
- // getUsername('http://www.linkedin.com/dhyasama/');
1341
- // getUsername('http://www.twitter.com/dhyasama?hello=world');
1342
- // getUsername('http://www.facebook.com');
1343
-
1344
1329
  self
1345
1330
  .find({ $or:
1346
1331
  [
1347
- { 'social.facebook': domains.facebook + '/' + username },
1348
- { 'social.linkedin': domains.linkedin + '/in/' + username },
1349
- { 'social.twitter': domains.twitter + '/' + username },
1350
- { 'crunchbase.url': domains.crunchbase + '/' + username }
1332
+ { 'social.facebook': new RegExp('facebook.com/' + username, 'i') },
1333
+ { 'social.linkedin': new RegExp('linkedin.com/company/' + username, 'i') },
1334
+ { 'social.twitter': new RegExp('twitter.com/' + username, 'i') },
1335
+ { 'crunchbase.url': new RegExp('crunchbase.com/organization/' + username, 'i') }
1351
1336
  ],
1352
1337
  'deleted': { $ne: true }
1353
1338
  })
package/lib/Person.js CHANGED
@@ -223,7 +223,7 @@ module.exports = function(mongoose, config) {
223
223
 
224
224
  Person.methods.addMerged = function(id) {
225
225
  if (this.merged.indexOf(id) == -1) {
226
- this.merged.push(id);
226
+ this.merged = this.merged.concat([id]);
227
227
  return true;
228
228
  }
229
229
  else {
@@ -715,45 +715,31 @@ module.exports = function(mongoose, config) {
715
715
  var getUsername = function getUsername(val) {
716
716
 
717
717
  var URL = require('url');
718
- var result = URL.parse(val);
718
+ var parsedUrl = URL.parse(val);
719
+ var protocol = parsedUrl.protocol;
719
720
 
720
- result = result.pathname;
721
+ if (!protocol) { parsedUrl = URL.parse('http://' + val); }
721
722
 
722
- if (result.indexOf('/') === 0) { result = result.replace('/', ''); }
723
- if (result.indexOf('in/') === 0) { result = result.replace('in/', ''); }
724
- if (result.indexOf('/') >= 0) { result = result.split('/')[0]; }
723
+ var pathname = parsedUrl.pathname;
725
724
 
726
- console.log(val, '-->', result);
725
+ if (pathname.indexOf('/') === 0) { pathname = pathname.replace('/', ''); }
726
+ if (pathname.indexOf('in/') === 0) { pathname = pathname.replace('in/', ''); }
727
+ if (pathname.indexOf('/') >= 0) { pathname = pathname.split('/')[0]; }
727
728
 
728
- return result;
729
+ console.log('Username:', val, '-->', pathname);
729
730
 
730
- };
731
+ return pathname;
731
732
 
732
- var domains = {
733
- facebook: 'https://facebook.com',
734
- linkedin: 'https://linkedin.com',
735
- twitter: 'https://twitter.com'
736
733
  };
737
734
 
738
735
  var username = getUsername(value);
739
736
 
740
- // todo - tests
741
- // getUsername('dhyasama');
742
- // getUsername('in/dhyasama');
743
- // getUsername('http://facebook.com/dhyasama');
744
- // getUsername('http://linkedin.com/in/dhyasama');
745
- // getUsername('https://twitter.com/dhyasama');
746
- // getUsername('http://www.facebook.com/dhyasama');
747
- // getUsername('http://www.linkedin.com/dhyasama/');
748
- // getUsername('http://www.twitter.com/dhyasama?hello=world');
749
- // getUsername('http://www.facebook.com');
750
-
751
737
  self
752
738
  .find({ $or:
753
739
  [
754
- { 'social.facebook': domains.facebook + '/' + username },
755
- { 'social.linkedin': domains.linkedin + '/in/' + username },
756
- { 'social.twitter': domains.twitter + '/' + username }
740
+ { 'social.facebook': new RegExp('facebook.com/' + username, 'i') },
741
+ { 'social.linkedin': new RegExp('linkedin.com/in/' + username, 'i') },
742
+ { 'social.twitter': new RegExp('twitter.com/' + username, 'i') }
757
743
  ],
758
744
  'deleted': { $ne: true }
759
745
  })
@@ -874,7 +860,7 @@ module.exports = function(mongoose, config) {
874
860
 
875
861
  this
876
862
  .find({ 'contact.email.email': { $in : emails }, 'deleted': {$ne: true}})
877
- .select('name avatarUrl')
863
+ .select('name avatarUrl title doNotDisplay')
878
864
  .exec(function (err, people) {
879
865
  cb(err, _.sortBy(people, function(person) { return person.name.full; }));
880
866
  });