@@ -44,6 +44,23 @@ pub async fn list_dashboards(req: HttpRequest) -> Result<impl Responder, Dashboa
4444 return Err ( DashboardError :: Metadata ( "Invalid limit value" ) ) ;
4545 }
4646 }
47+
48+ if let Some ( tags) = query_map. get ( "tags" ) {
49+ let tags: Vec < String > = tags
50+ . split ( ',' )
51+ . map ( |s| s. trim ( ) . to_string ( ) )
52+ . filter ( |s| !s. is_empty ( ) )
53+ . collect ( ) ;
54+ if tags. is_empty ( ) {
55+ return Err ( DashboardError :: Metadata ( "Tags cannot be empty" ) ) ;
56+ }
57+ let dashboards = DASHBOARDS . list_dashboards_by_tags ( tags) . await ;
58+ let dashboard_summaries = dashboards
59+ . iter ( )
60+ . map ( |dashboard| dashboard. to_summary ( ) )
61+ . collect :: < Vec < _ > > ( ) ;
62+ return Ok ( ( web:: Json ( dashboard_summaries) , StatusCode :: OK ) ) ;
63+ }
4764 }
4865 let dashboards = DASHBOARDS . list_dashboards ( dashboard_limit) . await ;
4966 let dashboard_summaries = dashboards
@@ -215,29 +232,6 @@ pub async fn list_tags() -> Result<impl Responder, DashboardError> {
215232 Ok ( ( web:: Json ( tags) , StatusCode :: OK ) )
216233}
217234
218- pub async fn list_dashboards_by_tags ( tags : Path < String > ) -> Result < impl Responder , DashboardError > {
219- let tags = tags. into_inner ( ) ;
220- if tags. is_empty ( ) {
221- return Err ( DashboardError :: Metadata ( "Tags cannot be empty" ) ) ;
222- }
223- // tags can be comma separated list of tags
224- let tags = tags
225- . split ( ',' )
226- . map ( |s| s. trim ( ) . to_string ( ) )
227- . filter ( |s| !s. is_empty ( ) )
228- . collect :: < Vec < _ > > ( ) ;
229- if tags. is_empty ( ) {
230- return Err ( DashboardError :: Metadata ( "Tags cannot be empty" ) ) ;
231- }
232- let dashboards = DASHBOARDS . list_dashboards_by_tags ( tags) . await ;
233- let dashboard_summaries = dashboards
234- . iter ( )
235- . map ( |dashboard| dashboard. to_summary ( ) )
236- . collect :: < Vec < _ > > ( ) ;
237-
238- Ok ( ( web:: Json ( dashboard_summaries) , StatusCode :: OK ) )
239- }
240-
241235#[ derive( Debug , thiserror:: Error ) ]
242236pub enum DashboardError {
243237 #[ error( "Failed to connect to storage: {0}" ) ]
0 commit comments