@@ -49,13 +49,16 @@ class TagCountService {
4949 * @param {Object } options - Module options
5050 * @returns {Promise<Array> } Promise resolving to [caseStudies, casesTags, businessPartners] arrays
5151 */
52- static async fetchCaseStudiesAndTags ( req , aposModules , options ) {
53- const [ caseStudies , casesTags , businessPartners ] = await Promise . all ( [
54- aposModules [ options . pieces ] . find ( req ) . toArray ( ) ,
52+ static async fetchCaseStudiesAndTags ( req , aposModules , options , caseStudies ) {
53+ const [ casesTags , businessPartners ] = await Promise . all ( [
5554 aposModules [ 'cases-tags' ] . find ( req ) . toArray ( ) ,
5655 aposModules [ 'business-partner' ] . find ( req ) . toArray ( ) ,
5756 ] ) ;
58- return [ caseStudies , casesTags , businessPartners ] ;
57+ let pieces = caseStudies ;
58+ if ( ! pieces ) {
59+ pieces = await aposModules [ options . pieces ] . find ( req ) . toArray ( ) ;
60+ }
61+ return [ pieces , casesTags , businessPartners ] ;
5962 }
6063
6164 /**
@@ -96,7 +99,7 @@ class TagCountService {
9699 * @param {Object } options - Module options
97100 * @returns {Promise<Object> } Tag counts by type
98101 */
99- static async calculateTagCounts ( req , aposModules , options ) {
102+ static async calculateTagCounts ( req , aposModules , options , caseStudiesInput ) {
100103 const tagCounts = {
101104 industry : { } ,
102105 stack : { } ,
@@ -105,7 +108,12 @@ class TagCountService {
105108 } ;
106109
107110 const [ caseStudies , casesTags , businessPartners ] =
108- await TagCountService . fetchCaseStudiesAndTags ( req , aposModules , options ) ;
111+ await TagCountService . fetchCaseStudiesAndTags (
112+ req ,
113+ aposModules ,
114+ options ,
115+ caseStudiesInput ,
116+ ) ;
109117
110118 const tagMap = TagCountService . createIdToSlugMap ( casesTags ) ;
111119 const partnerMap = TagCountService . createIdToSlugMap ( businessPartners ) ;
0 commit comments