@@ -7,6 +7,7 @@ use super::{
77 self , FunctionSummary , TopicAutomationConfig , TopicAutomationConfigPatch ,
88 TopicMapConfigPatch , TopicMapConfigUpdate , TopicMapGenerationSettings , TopicsConfigReport ,
99 } ,
10+ formatting:: { format_duration_compact, format_project_header} ,
1011 ConfigArgs , ConfigSetArgs , ResolvedContext , TopicMapSetArgs ,
1112} ;
1213
@@ -41,7 +42,7 @@ pub async fn run_set(ctx: &ResolvedContext, args: &ConfigSetArgs, json: bool) ->
4142
4243 print_command_status ( CommandStatus :: Success , "Updated Topics automation config" ) ;
4344 print_with_pager ( & render_single_config (
44- & report_header ( & ctx. project . name , & ctx. project . id , ctx. client . org_name ( ) ) ,
45+ & format_project_header ( & ctx. project . name , & ctx. project . id , ctx. client . org_name ( ) ) ,
4546 & updated,
4647 ) ) ?;
4748 Ok ( ( ) )
@@ -66,14 +67,14 @@ pub async fn run_topic_map_set(
6667
6768 print_command_status ( CommandStatus :: Success , "Updated Topics topic map config" ) ;
6869 print_with_pager ( & render_single_topic_map_update (
69- & report_header ( & ctx. project . name , & ctx. project . id , ctx. client . org_name ( ) ) ,
70+ & format_project_header ( & ctx. project . name , & ctx. project . id , ctx. client . org_name ( ) ) ,
7071 & updated,
7172 ) ) ?;
7273 Ok ( ( ) )
7374}
7475
7576fn render_report ( report : & TopicsConfigReport ) -> String {
76- let mut output = report_header (
77+ let mut output = format_project_header (
7778 & report. project . name ,
7879 & report. project . id ,
7980 & report. project . org_name ,
@@ -119,10 +120,6 @@ fn render_single_topic_map_update(header: &str, updated: &TopicMapConfigUpdate)
119120 output
120121}
121122
122- fn report_header ( project_name : & str , project_id : & str , org_name : & str ) -> String {
123- format ! ( "Project: {org_name} / {project_name} ({project_id})" )
124- }
125-
126123fn render_config_block ( automation : & TopicAutomationConfig ) -> String {
127124 let mut lines = vec ! [ format!( "{} ({})" , automation. name, automation. id) ] ;
128125 lines. push ( format ! (
@@ -382,26 +379,6 @@ fn format_sampling_percent(value: f64) -> String {
382379 }
383380}
384381
385- fn format_duration_compact ( seconds : Option < i64 > ) -> String {
386- let Some ( seconds) = seconds else {
387- return "n/a" . to_string ( ) ;
388- } ;
389-
390- let units = [
391- ( "w" , 7 * 24 * 60 * 60 ) ,
392- ( "d" , 24 * 60 * 60 ) ,
393- ( "h" , 60 * 60 ) ,
394- ( "m" , 60 ) ,
395- ( "s" , 1 ) ,
396- ] ;
397- for ( suffix, scale) in units {
398- if seconds >= scale && seconds % scale == 0 {
399- return format ! ( "{}{}" , seconds / scale, suffix) ;
400- }
401- }
402- format ! ( "{seconds}s" )
403- }
404-
405382fn format_float_compact ( value : f64 ) -> String {
406383 let rounded = value. round ( ) ;
407384 if ( value - rounded) . abs ( ) < 0.000_001 {
0 commit comments