@@ -140,13 +140,13 @@ pub struct Contributor {
140140#[ serde( rename_all = "camelCase" ) ]
141141pub struct ContributionCollection {
142142 #[ serde( rename = "totalCommitContributions" ) ]
143- commits : u64 ,
143+ commits : Option < u64 > ,
144144 #[ serde( rename = "totalPullRequestContributions" ) ]
145- pull_request : u64 ,
145+ pull_request : Option < u64 > ,
146146 #[ serde( rename = "totalIssueContributions" ) ]
147- issues : u64 ,
147+ issues : Option < u64 > ,
148148 #[ serde( rename = "totalRepositoryContributions" ) ]
149- repository : u64 ,
149+ repository : Option < u64 > ,
150150 #[ serde( skip) ]
151151 total : u64 ,
152152}
@@ -169,7 +169,12 @@ mod config {
169169
170170#[ cfg( feature = "ssr" ) ]
171171pub async fn fetch_contributors ( ) -> ContributorsResponse {
172+ println ! ( "DEBUG: Starting fetch_contributors()" ) ;
172173 let mut all_contributors = fetch_all_contributors_with_pagination ( ) . await ;
174+ println ! (
175+ "DEBUG: fetch_contributors returned {} contributors" ,
176+ all_contributors. len( )
177+ ) ;
173178
174179 all_contributors. sort_by_key ( |a| {
175180 a. contributions_collection
@@ -206,6 +211,17 @@ async fn fetch_all_contributors_with_pagination() -> Vec<Contributor> {
206211 )
207212 . await ;
208213
214+ println ! (
215+ "Fetched a page of repositories with {} nodes" ,
216+ response
217+ . organization
218+ . repositories
219+ . nodes
220+ . as_ref( )
221+ . map( |n| n. len( ) )
222+ . unwrap_or( 0 )
223+ ) ;
224+
209225 let repos = response. organization . repositories ;
210226
211227 for repo in repos. nodes . unwrap_or_default ( ) {
@@ -215,13 +231,19 @@ async fn fetch_all_contributors_with_pagination() -> Vec<Contributor> {
215231 }
216232
217233 let mut collab_page_info = collabs. page_info ;
234+ let repo_name = repo. name . clone ( ) ;
218235 while collab_page_info. has_next_page {
219236 let collab_cursor = collab_page_info. end_cursor . clone ( ) ;
220237
238+ println ! (
239+ "DEBUG: Fetching more collabs for repo '{}', repo_cursor={:?}, collab_cursor={:?}" ,
240+ repo_name, repo_cursor, collab_cursor
241+ ) ;
242+
221243 let collab_response = execute_repository_query (
222244 config:: ORGANIZATION_LOGIN ,
223245 1 ,
224- repo_cursor . clone ( ) ,
246+ None , // FIX: Use None to stay on the same repo, not the repo cursor
225247 config:: COLLAB_PAGE_SIZE ,
226248 collab_cursor,
227249 )
@@ -263,7 +285,10 @@ async fn fetch_all_contributors_with_pagination() -> Vec<Contributor> {
263285#[ cfg( feature = "ssr" ) ]
264286fn process_contributor ( seen : & mut HashMap < String , Contributor > , mut contributor : Contributor ) {
265287 if let Some ( cc) = contributor. contributions_collection . as_mut ( ) {
266- cc. total = cc. commits + cc. issues + cc. pull_request + cc. repository ;
288+ cc. total = cc. commits . unwrap_or ( 0 )
289+ + cc. issues . unwrap_or ( 0 )
290+ + cc. pull_request . unwrap_or ( 0 )
291+ + cc. repository . unwrap_or ( 0 ) ;
267292 if cc. total == 0 {
268293 cc. total = 1 ;
269294 }
@@ -292,6 +317,7 @@ async fn execute_repository_query(
292317) -> OrganizationData {
293318 let token = std:: env:: var ( "COLLABORATORS_API_TOKEN" ) . unwrap_or_default ( ) ;
294319 if token. is_empty ( ) {
320+ leptos:: logging:: warn!( "COLLABORATORS_API_TOKEN is empty or not set!" ) ;
295321 return empty_org_data ( ) ;
296322 }
297323
@@ -317,7 +343,10 @@ async fn execute_repository_query(
317343
318344 let text = match res {
319345 Ok ( r) => r. text ( ) . await . unwrap_or_default ( ) ,
320- Err ( _) => return empty_org_data ( ) ,
346+ Err ( e) => {
347+ leptos:: logging:: error!( "Request failed: {:?}" , e) ;
348+ return empty_org_data ( ) ;
349+ }
321350 } ;
322351
323352 let parsed: GithubResponse = match serde_json:: from_str ( & text) {
@@ -328,7 +357,17 @@ async fn execute_repository_query(
328357 }
329358 } ;
330359
331- parsed. data . unwrap_or_else ( empty_org_data)
360+ let org_data = parsed. data . unwrap_or_else ( empty_org_data) ;
361+ let repo_count = org_data
362+ . organization
363+ . repositories
364+ . nodes
365+ . as_ref ( )
366+ . map ( |n| n. len ( ) )
367+ . unwrap_or ( 0 ) ;
368+ println ! ( "DEBUG: Parsed org data, repos count: {}" , repo_count) ;
369+
370+ org_data
332371}
333372
334373#[ component]
0 commit comments