@@ -388,7 +388,8 @@ async def get_stats(self) -> None:
388388 """
389389 Get lots of summary statistics using one big query. Sets many attributes
390390 """
391- # Não inicializar stargazers e forks aqui, pois usaremos get_summary_stats
391+ self ._stargazers = 0
392+ self ._forks = 0
392393 self ._languages = dict ()
393394 self ._repos = set ()
394395
@@ -443,7 +444,8 @@ async def get_stats(self) -> None:
443444 self ._repos .add (name )
444445 processed_repos += 1
445446
446- # Não contar stars e forks aqui - usamos get_summary_stats para isso
447+ self ._stargazers += repo .get ("stargazers" , {}).get ("totalCount" , 0 )
448+ self ._forks += repo .get ("forkCount" , 0 )
447449
448450 for lang in repo .get ("languages" , {}).get ("edges" , []):
449451 lang_name = lang .get ("node" , {}).get ("name" , "Other" )
@@ -672,13 +674,42 @@ async def views(self) -> int:
672674 @property
673675 async def total_commits (self ) -> int :
674676 """
675- Get the total number of commits made by the user from all years .
677+ Get the total number of commits made by the user (igual ao script original) .
676678 """
677- # Sempre recalcular se for None para garantir contagem de todos os anos
678- if self ._total_commits is None :
679- await self .get_all_time_commits ()
680- assert self ._total_commits is not None
681- return self ._total_commits
679+ total_commits = 0
680+ if self ._emails :
681+ for email in self ._emails :
682+ query = f'''
683+ query {{
684+ user(login: "{ self .username } ") {{
685+ contributionsCollection {{
686+ totalCommitContributions
687+ }}
688+ }}
689+ }}
690+ '''
691+ response = await self .queries .query (query )
692+ if 'data' in response and 'user' in response ['data' ]:
693+ total_commit = response ['data' ]['user' ]['contributionsCollection' ]['totalCommitContributions' ]
694+ total_commits += total_commit
695+ else :
696+ print (f"Erro ao buscar commits para email { email } : { response } " )
697+ else :
698+ query = f'''
699+ query {{
700+ user(login: "{ self .username } ") {{
701+ contributionsCollection {{
702+ totalCommitContributions
703+ }}
704+ }}
705+ }}
706+ '''
707+ response = await self .queries .query (query )
708+ if 'data' in response and 'user' in response ['data' ]:
709+ total_commits = response ['data' ]['user' ]['contributionsCollection' ]['totalCommitContributions' ]
710+ else :
711+ print (f"Erro ao buscar commits para username { self .username } : { response } " )
712+ return total_commits
682713
683714 @property
684715 async def prs (self ) -> int :
0 commit comments