Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed TypeError when commit is being null. #464

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AyushAgnihotri2025
Copy link

@AyushAgnihotri2025 AyushAgnihotri2025 commented Jul 17, 2023

Closes #463
Closes #425

@AyushAgnihotri2025 AyushAgnihotri2025 changed the title Fixed TypeError commit is being null. Fixed TypeError when commit is being null. Jul 17, 2023
Copy link

@willnaoosmith willnaoosmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really test this right now, but looks like it should fix that issue.
BUT, if it doesn't, the code below should do the job for sure.

for commit in commit_data["data"]["repository"]["ref"]["target"]["history"]["nodes"]:
    try:
        if commit and commit["committedDate"]:
            date = search(r"\d+-\d+-\d+", commit["committedDate"]).group()
            curr_year = datetime.fromisoformat(date).year
            quarter = (datetime.fromisoformat(date).month - 1) // 3 + 1

            if repo_details["name"] not in date_data:
                date_data[repo_details["name"]] = dict()
            if branch["name"] not in date_data[repo_details["name"]]:
                date_data[repo_details["name"]][branch["name"]] = dict()
            date_data[repo_details["name"]][branch["name"]][commit["oid"]] = commit["committedDate"]

            if repo_details["primaryLanguage"] is not None:
                if curr_year not in yearly_data:
                    yearly_data[curr_year] = dict()
                if quarter not in yearly_data[curr_year]:
                    yearly_data[curr_year][quarter] = dict()
                if repo_details["primaryLanguage"]["name"] not in yearly_data[curr_year][quarter]:
                    yearly_data[curr_year][quarter][repo_details["primaryLanguage"]["name"]] = {"add": 0, "del": 0}
                yearly_data[curr_year][quarter][repo_details["primaryLanguage"]["name"]]["add"] += commit["additions"]
                yearly_data[curr_year][quarter][repo_details["primaryLanguage"]["name"]]["del"] += commit["deletions"]
    
    except Exception as error:
        DBM.p(f"A exception ocurred while getting the commit history! {str(error)}")
        continue

Thank you @AyushAgnihotri2025!

@willnaoosmith
Copy link

Merging when?

Copy link
Contributor

@thenithinbalaji thenithinbalaji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you merge it asap?

@pseusys
Copy link
Collaborator

pseusys commented May 2, 2024

I personally can't merge the PR until the CI workflow runs successfully and I also can't launch the workflow. I think, it should be triggered on push. @AyushAgnihotri2025, @willnaoosmith, could you please make sure the workflow runs successfully and, if not, investigate logs and fix errors?

P.S. also, if it's not a big deal, I would prefer if commit is not None: syntax as it is more explicit and clear.

@willnaoosmith
Copy link

@pseusys it finally did run correctly again!
@AyushAgnihotri2025 Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants