Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit c3d28ef

Browse files
author
Nick Litwin
committed
Update to remove deprecated lodash methods
1 parent 112aa59 commit c3d28ef

File tree

8 files changed

+26
-27
lines changed

8 files changed

+26
-27
lines changed

app/directives/external-account/external-account.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe('External Accounts Directive', function() {
121121
scope.linkedAccounts = null
122122
scope.$digest()
123123
expect(element.isolateScope().accountList).to.have.length(7)
124-
expect(_.all(_.pluck(element.isolateScope().accountList, 'status'))).to.be.false
124+
expect(_.every(_.map(element.isolateScope().accountList, 'status'))).to.be.false
125125
})
126126

127127
it('should link external account ', function() {

app/directives/page-state-header/page-state-header.directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import _ from 'lodash'
9595
function displayMoneyEarned(handle) {
9696
ProfileService.getUserFinancials(handle)
9797
.then(function(financials) {
98-
vm.moneyEarned = _.sum(_.pluck(financials, 'amount'))
98+
vm.moneyEarned = _.sum(_.map(financials, 'amount'))
9999

100100
if (!vm.moneyEarned) {
101101
$scope.hideMoney = true

app/my-challenges/my-challenges.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import _ from 'lodash'
8181
.then(function(data) {
8282
// data should be an array of 2 objects each with it's own array (2D array with metadata)
8383

84-
vm.totalCount = _.sum(_.pluck(data, 'metadata.totalCount'))
84+
vm.totalCount = _.sum(_.map(data, 'metadata.totalCount'))
8585
vm.myChallenges = vm.myChallenges.concat(_.union(data[0], data[1]))
8686
if (vm.totalCount === 0) {
8787
_checkForParticipation().then(function() {

app/profile/subtrack/subtrack.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ import _ from 'lodash'
8585
var mustHaveMetrics = ['rank', 'rating', 'reliability']
8686
// check if rating, rank & reliability are all set
8787
var _filteredObjs = _.filter(vm.subTrackStats, function(k) { return _.indexOf(mustHaveMetrics, k.label) > -1})
88-
if (_.all(_.pluck(_filteredObjs, 'val'), function(v) { return !v})) {
88+
if (_.all(_.map(_filteredObjs, 'val'), function(v) { return !v})) {
8989
// all false filter em out
9090
_.remove(vm.subTrackStats, function(k) { return _.indexOf(mustHaveMetrics, k.label) > -1})
9191
}

app/services/externalAccounts.service.spec.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ describe('ExternalAccount Service', function() {
1212
var auth0, userService
1313
var profileGet, profilePost, profileDelete
1414

15-
1615
beforeEach(function() {
1716
bard.appModule('topcoder')
1817
bard.inject(this, 'ExternalAccountService', '$httpBackend', '$q', 'CONSTANTS', 'JwtInterceptorService', 'auth', 'UserService')
@@ -91,8 +90,8 @@ describe('ExternalAccount Service', function() {
9190
// spy
9291
service.getAllExternalLinks('test1', 111, false).then(function(data) {
9392
expect(data).to.be.defined
94-
expect(_.pluck(data, 'provider')).to.include.members(['dribbble', 'github','bitbucket', 'stackoverflow'])
95-
expect(_.all(_.pluck(data, 'data'))).to.be.truthy
93+
expect(_.map(data, 'provider')).to.include.members(['dribbble', 'github','bitbucket', 'stackoverflow'])
94+
expect(_.all(_.map(data, 'data'))).to.be.truthy
9695
})
9796
$httpBackend.flush()
9897
})
@@ -101,7 +100,7 @@ describe('ExternalAccount Service', function() {
101100
// spy
102101
service.getAllExternalLinks('test1', 111, true).then(function(data) {
103102
expect(data).to.be.defined
104-
expect(_.pluck(data, 'provider')).to.include.members(['dribbble', 'github', 'behance', 'bitbucket','stackoverflow'])
103+
expect(_.map(data, 'provider')).to.include.members(['dribbble', 'github', 'behance', 'bitbucket','stackoverflow'])
105104
expect(data).to.have.length(5)
106105
var nullAccounts = _.remove(data, function(n) {return n.data.status === 'PENDING'})
107106
expect(nullAccounts).to.have.length(1)
@@ -116,8 +115,8 @@ describe('ExternalAccount Service', function() {
116115
// spy
117116
service.getAllExternalLinks('test1', 111, true).then(function(data) {
118117
expect(data).to.be.defined
119-
expect(_.pluck(data, 'provider')).to.include.members(['dribbble', 'github','bitbucket', 'stackoverflow'])
120-
expect(_.all(_.pluck(data, 'data'))).to.be.truthy
118+
expect(_.map(data, 'provider')).to.include.members(['dribbble', 'github','bitbucket', 'stackoverflow'])
119+
expect(_.all(_.map(data, 'data'))).to.be.truthy
121120
})
122121
$httpBackend.flush()
123122
})

app/services/externalLinks.service.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ import _ from 'lodash'
3434
})
3535
}
3636
// add provider type as weblink
37-
links = _(links).forEach(function(l) {
38-
l.provider = 'weblink'
39-
if (l.synchronizedAt === 0) {
40-
l.status = 'PENDING'
37+
links.forEach(function(l, i, array) {
38+
array[i].provider = 'weblink'
39+
if (array[i].synchronizedAt === 0) {
40+
array[i].status = 'PENDING'
4141
}
42-
}).value()
42+
})
4343
return links
4444
})
4545
}

app/services/userStats.service.spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,30 @@ describe('User Stats Service', function() {
2929
var _data = UserStatsService.getIterableStats('DEVELOP', 'ASSEMBLY_COMPETITION', stats)
3030
expect(_data).to.have.length(6)
3131

32-
expect(_.pluck(_data, 'val')).to.have.members(['1,733', '25', '95%', '16', '10', '80%'])
33-
expect(_.pluck(_data, 'label')).to.have.members(['rating', 'rank', 'percentile', 'challenges', 'wins', 'reliability'])
32+
expect(_.map(_data, 'val')).to.have.members(['1,733', '25', '95%', '16', '10', '80%'])
33+
expect(_.map(_data, 'label')).to.have.members(['rating', 'rank', 'percentile', 'challenges', 'wins', 'reliability'])
3434
})
3535

3636
it('should return stats for design-webdesign ', function() {
3737
var _data = UserStatsService.getIterableStats('DESIGN', 'WEB_DESIGNS', stats)
3838
expect(_data).to.have.length(2)
39-
expect(_.pluck(_data, 'val')).to.have.members(['190','418'])
40-
expect(_.pluck(_data, 'label')).to.have.members(['wins', 'challenges'])
39+
expect(_.map(_data, 'val')).to.have.members(['190','418'])
40+
expect(_.map(_data, 'label')).to.have.members(['wins', 'challenges'])
4141
})
4242

4343
it('should return stats for data-science: srms ', function() {
4444
var _data = UserStatsService.getIterableStats('DATA_SCIENCE', 'SRM', stats)
4545
expect(_data).to.have.length(5)
46-
expect(_.pluck(_data, 'label')).to.have.members(['rating', 'rank', 'percentile', 'competitions', 'volatility'])
47-
expect(_.pluck(_data, 'val')).to.have.members(['799', '6,280', '26%', '10', '473'])
46+
expect(_.map(_data, 'label')).to.have.members(['rating', 'rank', 'percentile', 'competitions', 'volatility'])
47+
expect(_.map(_data, 'val')).to.have.members(['799', '6,280', '26%', '10', '473'])
4848
})
4949

5050

5151
it('should return stats for Copilot ', function() {
5252
var _data = UserStatsService.getIterableStats('COPILOT', 'COPILOT', stats)
5353
expect(_data).to.have.length(5)
54-
expect(_.pluck(_data, 'label')).to.have.members(['active challenges', 'active projects', 'total challenges', 'total projects', 'fulfillment'])
55-
expect(_.pluck(_data, 'val')).to.have.members([0, '1', '24', '3', '84%'])
54+
expect(_.map(_data, 'label')).to.have.members(['active challenges', 'active projects', 'total challenges', 'total projects', 'fulfillment'])
55+
expect(_.map(_data, 'val')).to.have.members([0, '1', '24', '3', '84%'])
5656
})
5757
})
5858

@@ -322,7 +322,7 @@ describe('User Stats Service', function() {
322322
}]
323323
var filtered = UserStatsService.filterStats(toTest)
324324
expect(filtered).to.exist.to.have.length(3)
325-
expect(_.pluck(filtered, 'showStats')).to.have.members([true, true, true])
325+
expect(_.map(filtered, 'showStats')).to.have.members([true, true, true])
326326
})
327327
})
328328

app/skill-picker/skill-picker.controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import _ from 'lodash'
5656
* Verfies if the communities section state has been modified by the user in any way.
5757
*/
5858
function isCommunitiesDirty() {
59-
var community = _.findWhere(vm.communities, {dirty: true})
59+
var community = _.find(vm.communities, {dirty: true})
6060
return !!community
6161
}
6262

@@ -97,7 +97,7 @@ import _ from 'lodash'
9797
vm.loadingCommunities = false
9898
responses.forEach(function(program) {
9999
if (program) {
100-
var community = _.findWhere(vm.communities, {programId: program.eventId})
100+
var community = _.find(vm.communities, {programId: program.eventId})
101101
if (community) {
102102
// set display false to avoid showing already enabled/registered program
103103
// we expect display property to be modified after first load of the page
@@ -111,7 +111,7 @@ import _ from 'lodash'
111111
}
112112
})
113113
// if there exists at least 1 community which can be displayed, set showCommunity flag to true
114-
var community = _.findWhere(vm.communities, {display: true})
114+
var community = _.find(vm.communities, {display: true})
115115
if (community) {
116116
vm.showCommunity = true
117117
}

0 commit comments

Comments
 (0)