@@ -142,48 +142,25 @@ angular.module('topcoderX')
142142
143143 /**
144144 * Get associated connect projects that the current user has access to
145+ * @param perPage the items to retrieve per page
146+ * @param page the page index
145147 */
146- ProjectService . getConnectProjects = function ( ) {
147- function createProjectRequest ( pagingParams ) {
148- return $http ( {
149- method : 'GET' ,
150- url : $rootScope . appConfig . TC_API_V5_URL + '/projects/' ,
151- headers : {
152- "Content-Type" : "application/json" ,
153- "Authorization" : "Bearer " + AuthService . AuthService . getTokenV3 ( )
154- } ,
155- params : {
156- fields : 'id,name,status' ,
157- sort : 'lastActivityAt desc' ,
158- perPage : pagingParams . perPage ,
159- page : pagingParams . page
160- }
161- } ) ;
162- }
163-
164- function getAll ( getter , perPage , page , prev ) {
165- return getter ( {
148+ ProjectService . getConnectProjects = function ( perPage , page ) {
149+ return $http ( {
150+ method : 'GET' ,
151+ url : $rootScope . appConfig . TC_API_V5_URL + '/projects/' ,
152+ headers : {
153+ "Content-Type" : "application/json" ,
154+ "Authorization" : "Bearer " + AuthService . getTokenV3 ( )
155+ } ,
156+ params : {
157+ fields : 'id,name,status' ,
158+ sort : 'lastActivityAt desc' ,
166159 perPage : perPage ,
167160 page : page
168- } ) . then ( function ( res ) {
169- if ( res . status === 200 ) {
170- var data = res . data ;
171- if ( ! data . length ) return prev || [ ] ;
172- var current = [ ] ;
173- if ( prev ) {
174- current = prev . concat ( data ) ;
175- } else {
176- current = data ;
177- }
178- return getAll ( getter , perPage , 1 + page , current ) ;
179- }
180- return prev || [ ] ;
181- } ) ;
182- }
183- return getAll ( function ( params ) { return createProjectRequest ( params ) } , 20 , 1 ) . then ( function ( response ) {
184- return response ;
161+ }
185162 } ) ;
186- }
163+ } ;
187164
188165 return ProjectService ;
189166 } ] ) ;
0 commit comments