@@ -54,7 +54,7 @@ const createReportController = (reportType) => {
5454
5555 /*
5656 // Validate supported parameters
57- const supportedParams = ['technology', 'geo', 'rank', 'start', 'end'];
57+ const supportedParams = ['technology', 'geo', 'rank', 'start', 'end', 'version' ];
5858 const providedParams = Object.keys(params);
5959 const unsupportedParams = providedParams.filter(param => !supportedParams.includes(param));
6060
@@ -77,8 +77,15 @@ const createReportController = (reportType) => {
7777 return ;
7878 }
7979
80- // Validate and process technology array
81- const techArray = validateArrayParameter ( params . technology , 'technology' ) ;
80+ // Validate and process technologies
81+ const technologiesArray = validateArrayParameter ( params . technology , 'technology' ) ;
82+
83+ // Validate and process versions
84+ // Apply version filter with special handling for 'ALL' case
85+ let versionsArray = [ 'ALL' ] ;
86+ if ( technologiesArray . length === 1 && params . version ) {
87+ versionsArray = validateArrayParameter ( params . version , 'version' ) ;
88+ }
8289
8390 // Handle 'latest' date substitution
8491 let startDate = params . start ;
@@ -90,7 +97,8 @@ const createReportController = (reportType) => {
9097 const queryFilters = {
9198 geo : params . geo ,
9299 rank : params . rank ,
93- technology : techArray ,
100+ technology : technologiesArray ,
101+ version : versionsArray ,
94102 startDate : startDate ,
95103 endDate : params . end
96104 } ;
@@ -112,21 +120,21 @@ const createReportController = (reportType) => {
112120 query = query . where ( 'rank' , '==' , params . rank ) ;
113121
114122 // Apply technology filter with batch processing
115- query = query . where ( 'technology' , 'in' , techArray ) ;
123+ query = query . where ( 'technology' , 'in' , technologiesArray ) ;
116124
117- // Apply version filter with special handling for 'ALL' case
118- if ( params . version && techArray . length === 1 ) {
119- query = query . where ( 'version' , '==' , params . version ) ;
120- } else {
121- query = query . where ( 'version' , '==' , 'ALL' ) ;
122- }
125+ // Apply version filter with batch processing
126+ query = query . where ( 'version' , 'in' , versionsArray ) ;
123127
124128 // Apply date filters
125129 if ( startDate ) query = query . where ( 'date' , '>=' , startDate ) ;
126130 if ( params . end ) query = query . where ( 'date' , '<=' , params . end ) ;
127131
128132 // Apply field projection to optimize query
129- query = query . select ( 'date' , 'technology' , config . dataField ) ;
133+ const selectFields = [ 'date' , 'technology' , config . dataField ] ;
134+ if ( ! ( versionsArray . length === 1 && versionsArray [ 0 ] === 'ALL' ) ) {
135+ selectFields . push ( 'version' ) ;
136+ }
137+ query = query . select ( ...selectFields ) ;
130138
131139 // Execute query
132140 const snapshot = await query . get ( ) ;
0 commit comments