11use anyhow:: Context ;
22use chrono:: { Datelike , NaiveDate } ;
33use rust_project_goals:: markwaydown;
4- use rust_project_goals:: re:: HELP_WANTED ;
4+ use rust_project_goals:: re:: { HELP_WANTED , TLDR } ;
55use rust_project_goals:: util:: comma;
66use rust_project_goals_json:: GithubIssueState ;
77use std:: io:: Write ;
@@ -114,11 +114,19 @@ async fn prepare_goals(
114114 comments. sort_by_key ( |c| c. created_at . clone ( ) ) ;
115115 comments. retain ( |c| !c. is_automated_comment ( ) && filter. matches ( c) ) ;
116116
117+ let tldr = tldr ( & issue_id, & mut comments) ?;
117118
118- let help_wanted = help_wanted ( & issue_id, issue ) ?;
119+ let help_wanted = help_wanted ( & issue_id, & comments ) ?;
119120
120121 let why_this_goal = why_this_goal ( & issue_id, issue) ?;
121122
123+ progress_bar:: print_progress_bar_info (
124+ & format ! ( "Issue #{number}" , number = issue. number) ,
125+ & format ! ( "tldr={}, c={}" , tldr. is_some( ) , comments. len( ) ) ,
126+ progress_bar:: Color :: Green ,
127+ progress_bar:: Style :: Bold ,
128+ ) ;
129+
122130 result. push ( UpdatesGoal {
123131 title : title. clone ( ) ,
124132 issue_number : issue. number ,
@@ -129,7 +137,7 @@ async fn prepare_goals(
129137 is_closed : issue. state == GithubIssueState :: Closed ,
130138 num_comments : comments. len ( ) ,
131139 comments,
132- tldr : None , // FIXME
140+ tldr,
133141 why_this_goal,
134142 } ) ;
135143
@@ -138,15 +146,29 @@ async fn prepare_goals(
138146 Ok ( result)
139147}
140148
149+ /// Search for a TL;DR comment. If one is found, remove it and return the text.
150+ fn tldr (
151+ _issue_id : & IssueId ,
152+ comments : & mut Vec < ExistingGithubComment > ,
153+ ) -> anyhow:: Result < Option < String > > {
154+ let Some ( index) = comments. iter ( ) . position ( |c| c. body . starts_with ( TLDR ) ) else {
155+ return Ok ( None ) ;
156+ } ;
157+
158+ let comment = comments. remove ( index) ;
159+ Ok ( Some ( comment. body [ TLDR . len ( ) ..] . trim ( ) . to_string ( ) ) )
160+ }
161+
162+ /// Search for comments that talk about help being wanted and extract that
141163fn help_wanted (
142- issue_id : & IssueId ,
143- issue : & ExistingGithubIssue ,
164+ _issue_id : & IssueId ,
165+ comments : & [ ExistingGithubComment ] ,
144166) -> anyhow:: Result < Vec < HelpWanted > > {
145167 use std:: fmt:: Write ;
146168
147169 let mut help_wanted = vec ! [ ] ;
148170
149- for comment in & issue . comments {
171+ for comment in comments {
150172 let mut lines = comment. body . split ( '\n' ) . peekable ( ) ;
151173
152174 // Look for a line that says "Help wanted" at the front.
0 commit comments