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

Contribution count in Org report is not limited to date range #143

Closed
kontu opened this issue Jul 2, 2024 · 8 comments · Fixed by #165
Closed

Contribution count in Org report is not limited to date range #143

kontu opened this issue Jul 2, 2024 · 8 comments · Fixed by #165
Assignees
Labels
bug Something isn't working

Comments

@kontu
Copy link

kontu commented Jul 2, 2024

Describe the bug

When generating the report against an Organization using start_date and end_date, the Contributions Count is equal to the all time contributions for any repos in the report

In a report created, Top contributor has contributed to one repo in the time span. See screenshots for
I would expect their Contribution Count to be ~8 in the report; not 476

To Reproduce

  • Create new repo with only this action with below code to get a short weeks period
  • Trigger report generation via workflow_dispatch
name: Weekly contributor report
on:
  workflow_dispatch:
  # schedule:
  #   - cron: '0 4 * * 1'

permissions:
  contents: read

jobs:
  contributor_report:
    name: contributor report
    runs-on: ubuntu-latest
    permissions:
      issues: write

    steps:
      - name: Get dates for last week
        shell: bash
        run: |
          # Calculate the first day of the previous week
          start_date=$(date -d "last-sunday" +%Y-%m-%d)
  
          # Calculate the last day of the previous week
          end_date=$(date -d "$start_date +1 week -1 day" +%Y-%m-%d)
  
          #Set an environment variable with the date range
          echo "START_DATE=$start_date" >> "$GITHUB_ENV"
          echo "START_DATE=$start_date"
          echo "END_DATE=$end_date" >> "$GITHUB_ENV"
          echo "END_DATE=$end_date"

  
      - name: Run contributor action
        uses: github/contributors@v1.4.3
        env:
          GH_APP_ID: ${{ secrets.GH_APP_ID }}
          GH_APP_INSTALLATION_ID: ${{ secrets.GH_APP_INSTALLATION_ID }}
          GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
          START_DATE: ${{ env.START_DATE }}
          END_DATE: ${{ env.END_DATE }}
          ORGANIZATION: "XXXX"
          SPONSOR_INFO: "false"
      - name: Create issue
        uses: peter-evans/create-issue-from-file@v5
        with:
          title: Contributor report for ${{ env.START_DATE }} - ${{ env.END_DATE }}
          content-filepath: ./contributors.md
          assignees: xxxxxxxxx

Expected behavior

  • User has contributed in the date range
  • Contribution Count reflects contributions performed only during the date range

Screenshots

Generated report for 1 week: image
image

Additional context

Referencing reports in this repo to narrow down when this changed

  • Monthly contributor report #56 seems to correctly only count contributions from the time period
  • Monthly contributor report #61 is the first report I find in this repo that shows total contribution count instead of time period
  • This makes me suspect it may have been introduced around release v1.1.2 ; however as i have installed as github app I can not downgrade to test at this time
@kontu kontu added the bug Something isn't working label Jul 2, 2024
@zkoppert
Copy link
Member

I believe what you are seeing here is that there are things that count as contributions that you wouldn't expect. ie. more than code commits.

Here is the github api endpoint we are using. Notice in the api response example it says "contributions: 32". That is the number we are relaying into this action.

The value of contribution has a list of things that increase that count.

  • Committing to a repository's default branch or gh-pages branch
  • Creating a branch
  • Opening an issue
  • Opening a discussion
  • Answering a discussion
  • Proposing a pull request
  • Submitting a pull request review

@zkoppert zkoppert self-assigned this Aug 21, 2024
@kontu
Copy link
Author

kontu commented Aug 21, 2024

I do not believe what I am seeing is the difference.
In my example pic showing 476 contributions as the top contributor, it is impossible that these other items make up the difference. That repo is rarely used, only has 2 people who commit to it. Rarely PR's, never issues or discussions or other items. Certainly not 468 other actions in that week timespan defined. The user has made roughly ~450 commits to the repo since it's inception some years back though, which is more inline to the value returned.

@zkoppert
Copy link
Member

Hmm interesting! Let me take a look a few other places to see what I can find.

@zkoppert
Copy link
Member

I don't see anywhere in the code where the contributions are filtered down by the dates given.

contributor = contributor_stats.ContributorStats( user.login, False, user.avatar_url, user.contributions_count, commit_url, "", )

And user.contributions_count is set by the GitHub Python api wrapper directly without considering start and end date variables.

Our options are either to switch to commit counts or relabel the data to all time contributions.

@kontu
Copy link
Author

kontu commented Aug 25, 2024

Looks awesome can't wait to see it in a release!

@zkoppert
Copy link
Member

Just released!!

@kontu
Copy link
Author

kontu commented Aug 25, 2024

image

Ran using @1.5.0, doesn't seem to have fixed the issue quite. I should have under 20 contributions; and 528 matches the result from action contributors@1.4.3

@zkoppert
Copy link
Member

Yeah, we changed the column headers to reflect that these are all time commits. We couldn't fix the commit numbers due to limitations in the GitHub API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants