diff --git a/src/helpers/programHelper.js b/src/helpers/programHelper.js index 0558ddb4dd4971e07740065759f6ce406569f87c..04ecc75e34414fe0204a21a4dc113b16b61ec401 100644 --- a/src/helpers/programHelper.js +++ b/src/helpers/programHelper.js @@ -317,6 +317,7 @@ class ProgramServiceHelper { item.children = children; }); } + const aggregations = contribution.data && contribution.data.result && contribution.data.result.aggregations; const contentCount = this.approvedContentCount(hierarchyArr, program_id, aggregations); resolve(contentCount); @@ -340,15 +341,18 @@ class ProgramServiceHelper { this.collectionData['totalContentsReviewed'] = (_.union(this.acceptedContents, this.rejectedContents)).length; this.collectionData['contributionsReceived'] = 0; - _.forEach(collection.children, (unit) => { - _.forEach(unit.children, (chapter) => { - if (chapter.status === 'Live' - && chapter.mimeType !== 'application/vnd.ekstep.content-collection' - && chapter.contentType !== 'Asset') { - this.collectionData['contributionsReceived']++; - } - }); - }); + // Count of contribution + if (contributionResponse.length && contributionResponse[0].name === 'collectionId' + && contributionResponse[0].values.length) { + const statusCount = _.find(contributionResponse[0].values, {name: collection.identifier}); + if (statusCount && statusCount.aggregations && statusCount.aggregations.length) { + _.forEach(statusCount.aggregations[0].values, (obj) => { + if (obj.name === 'live') { + this.collectionData['contributionsReceived'] = this.collectionData['contributionsReceived'] + obj.count; + } + }); + } + } this.collectionLevelCount(collection); return this.collectionData