@@ -9,7 +9,7 @@ use crate::{
99 schema:: {
1010 Dashboard , DashboardBuilder , DataLink , Datasource , FieldConfig , FieldConfigCustom ,
1111 FieldConfigDefaults , GridPos , LogPanel , Panel , QueryVariable , QueryVariableQuery , Target ,
12- TextBoxVariable , TimeSeriesPanel , Transformation ,
12+ TextBoxVariable , TimeSeriesPanel , Transformation , VariableSortOrder ,
1313 } ,
1414 sql:: Query ,
1515 util:: UrlBuilder ,
@@ -101,6 +101,8 @@ pub fn extra_dashboard(config: &TeamConfig) -> Result<Dashboard> {
101101 builder. add_application_variable ( config) ?;
102102 builder. add_channel_variable ( ) ;
103103 builder. add_variable ( error_type_variable ( ) ) ;
104+ builder. add_variable ( version_variable ( ) ) ;
105+ builder. add_variable ( build_date_variable ( ) ) ;
104106 builder. add_variable ( TextBoxVariable {
105107 label : "Search details" . into ( ) ,
106108 name : "details" . into ( ) ,
@@ -134,19 +136,72 @@ ORDER BY metrics.string.rust_component_errors_error_type",
134136 }
135137}
136138
139+ pub fn version_variable ( ) -> QueryVariable {
140+ let query = QueryVariableQuery :: from_sql (
141+ "\
142+ SELECT 'All' as text, '' as value
143+ UNION ALL
144+ SELECT version as text, version as value
145+ FROM (
146+ SELECT DISTINCT CAST(mozfun.norm.extract_version(client_info.app_display_version, 'major') AS STRING) as version
147+ FROM mozdata.fenix.rust_component_errors
148+ WHERE submission_timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 14 day)
149+ AND mozfun.norm.extract_version(client_info.app_display_version, 'major') IS NOT NULL
150+ ORDER BY 1 DESC
151+ )" ,
152+ ) ;
153+
154+ QueryVariable {
155+ label : "Version" . into ( ) ,
156+ name : "version" . into ( ) ,
157+ datasource : Datasource :: bigquery ( ) ,
158+ query,
159+ sort : Some ( VariableSortOrder :: AlphabeticalDescending ) ,
160+ ..QueryVariable :: default ( )
161+ }
162+ }
163+
164+ pub fn build_date_variable ( ) -> QueryVariable {
165+ let query = QueryVariableQuery :: from_sql (
166+ "\
167+ SELECT 'None' as text, '' as value
168+ UNION ALL
169+ SELECT build_date as text, build_date as value
170+ FROM (
171+ SELECT DISTINCT SUBSTR(client_info.build_date, 0, 10) as build_date
172+ FROM mozdata.fenix.rust_component_errors
173+ WHERE submission_timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 14 day)
174+ ORDER BY 1 DESC
175+ )" ,
176+ ) ;
177+
178+ QueryVariable {
179+ label : "Group by build date" . into ( ) ,
180+ name : "build_date" . into ( ) ,
181+ datasource : Datasource :: bigquery ( ) ,
182+ sort : Some ( VariableSortOrder :: AlphabeticalDescending ) ,
183+ query,
184+ ..QueryVariable :: default ( )
185+ }
186+ }
187+
137188fn error_list_count_panel ( ) -> Panel {
138189 let mut query = Query {
139- select : vec ! [ "$__timeGroup(submission_timestamp, $__interval) as time" . into( ) ] ,
190+ select : vec ! [
191+ "$__timeGroup(submission_timestamp, $__interval) as time" . into( ) ,
192+ "IF('${build_date}' = '', '', IF(build_date < '${build_date}', '< ${build_date}', '>= ${build_date}')) as build_date" . into( ) ,
193+ ] ,
140194 where_ : vec ! [
141195 "error_type='${error_type}'" . into( ) ,
142196 "$__timeFilter(submission_timestamp)" . into( ) ,
143197 "normalized_channel = '${channel}'" . into( ) ,
144- "('${details}' = '' OR details LIKE '%${details}%')" . into( ) ,
198+ "'${version}' = '' OR version = CAST('${version}' AS NUMERIC)" . into( ) ,
199+ "'${details}' = '' OR details LIKE '%${details}%'" . into( ) ,
145200 "${filter_sql}" . into( ) ,
146201 ] ,
147202 from : error_subquery ( ) . as_subquery ( ) ,
148- group_by : Some ( "1" . into ( ) ) ,
149- order_by : Some ( "time DESC " . into ( ) ) ,
203+ group_by : Some ( "1, 2 " . into ( ) ) ,
204+ order_by : Some ( "1 ASC, 2 ASC " . into ( ) ) ,
150205 ..Query :: default ( )
151206 } ;
152207 query. add_count_per_day_column ( "COUNT(*)" , "errors" ) ;
@@ -183,6 +238,7 @@ fn error_list_log_panel() -> Panel {
183238 "error_type='${error_type}'" . into( ) ,
184239 "$__timeFilter(submission_timestamp)" . into( ) ,
185240 "normalized_channel = '${channel}'" . into( ) ,
241+ "'${version}' = '' OR version = CAST('${version}' AS NUMERIC)" . into( ) ,
186242 "('${details}' = '' OR details LIKE '%${details}%')" . into( ) ,
187243 "${filter_sql}" . into( ) ,
188244 ] ,
@@ -210,6 +266,9 @@ fn error_list_log_panel() -> Panel {
210266fn error_subquery ( ) -> Query {
211267 let mut subquery = Query {
212268 select : vec ! [
269+ "SUBSTR(client_info.build_date, 0, 10) as build_date" . into( ) ,
270+ "mozfun.norm.extract_version(client_info.app_display_version, 'major') as version"
271+ . into( ) ,
213272 "metrics.string.rust_component_errors_error_type as error_type" . into( ) ,
214273 "metrics.string.rust_component_errors_details as details" . into( ) ,
215274 "metrics.string_list.rust_component_errors_breadcrumbs as breadcrumbs" . into( ) ,
0 commit comments