@@ -54,7 +54,7 @@ const createReportController = (reportType) => {
54
54
55
55
/*
56
56
// Validate supported parameters
57
- const supportedParams = ['technology', 'geo', 'rank', 'start', 'end'];
57
+ const supportedParams = ['technology', 'geo', 'rank', 'start', 'end', 'version' ];
58
58
const providedParams = Object.keys(params);
59
59
const unsupportedParams = providedParams.filter(param => !supportedParams.includes(param));
60
60
@@ -77,8 +77,15 @@ const createReportController = (reportType) => {
77
77
return ;
78
78
}
79
79
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
+ }
82
89
83
90
// Handle 'latest' date substitution
84
91
let startDate = params . start ;
@@ -90,7 +97,8 @@ const createReportController = (reportType) => {
90
97
const queryFilters = {
91
98
geo : params . geo ,
92
99
rank : params . rank ,
93
- technology : techArray ,
100
+ technology : technologiesArray ,
101
+ version : versionsArray ,
94
102
startDate : startDate ,
95
103
endDate : params . end
96
104
} ;
@@ -112,21 +120,21 @@ const createReportController = (reportType) => {
112
120
query = query . where ( 'rank' , '==' , params . rank ) ;
113
121
114
122
// Apply technology filter with batch processing
115
- query = query . where ( 'technology' , 'in' , techArray ) ;
123
+ query = query . where ( 'technology' , 'in' , technologiesArray ) ;
116
124
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 ) ;
123
127
124
128
// Apply date filters
125
129
if ( startDate ) query = query . where ( 'date' , '>=' , startDate ) ;
126
130
if ( params . end ) query = query . where ( 'date' , '<=' , params . end ) ;
127
131
128
132
// 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 ) ;
130
138
131
139
// Execute query
132
140
const snapshot = await query . get ( ) ;
0 commit comments