Package: prfiesta
prfiesta 🦜🥳Collect and Analyze Individual Contributor Pull Requestsprfiestaallows you to collect, analyze and celebrate pull requests made by an individual 🎉.It can be used by engineers or managers to gain insights into all the great work the contributor has made over a specified period of time. A great use case of this tool is during a performance review process when you want to perform analysis on all the contributions made over the year.Installpython-mpipinstallprfiestaDependencies:Python 3.8+Usage# Authenticate yourselfexportGITHUB_TOKEN=...# or GITHUB_ENTERPRISE_TOKEN# Get all pull requests for a userprfiesta-ukiran94# Get all pull requests for a user created after a dateprfiesta-ukiran94--after2023-01-01# Get all pull requests for a user created between two datesprfiesta-ukiran94--after2023-01-01--before2023-06-01# Get all pull requests for a user updated after a dateprfiesta-ukiran94--after2023-01-01--use-updated# Get all pull requests with a custom output file nameprfiesta-ukiran94--outputmy_pull_requests.csv# Get all pull requests in parquet format with a custom file nameprfiesta-ukiran94--output-typeparquet--outputmy_pull_requests.parquet# Get all pull requests and export to a duckdb databaseprfiesta-ukiran94--output-typeduckdb--outputmydatabase.duckdb# Get all pull requests for more then one userprfiesta-ukiran94-uuser2# Get all pull requests and drop specific columns from the outputprfiesta-ukiran94-dcevents_url-dccomments_url-dcnode_id# Get all pull requests where the user was involved (as opposed to just authored)prfiesta-ukiran94--use-involves# Get all pull requests where the user reviewed it rather then being the authorprfiesta-ucharliermarsh--after2023-05-01--use-reviewed-by# Get all pull requests where the user was requested a review rather then being the authorprfiesta-ucharliermarsh--after2023-05-01--use-review-requested# Get all pull requests which contains a reference (e.g JIRA card reference) within the PR title or bodyprfiesta--referencePA-12765# Get helpprfiesta--help# Show the current versionprfiesta--versionYou can also leverageprfiestadirectly in your own application:importpandasaspdfromdatetimeimportdatetimefromprfiesta.collectors.githubimportGitHubCollectorgithub=GitHubCollector()frame:pd.DataFrame=github.collect('kiran94','user2',after=datetime(2023,1,1))print(frame)OutputYou can control the output type using the--output-typeoption. Supported options:csv(default)parquetduckdbYou can also customize the output file name using the--outputoption. When usingduckdb, this argument is the duckdb database that we should export into. You can see an example of a duckdb workflowhere.User FilterBy default,prfiestawill take the users provided in the--useroption and search the Git provider for any pull requests that the userauthored. Within more collaborative environments, this may not be what you want as you may want to also gain some visibility into all secondary contributions a user made (e.g commenting on others pull requests).The options listed here are mutually exclusive.User Involvementprfiestaexposes the--use-involvesflag which will search for pull requests that were:Created by a certain userAssigned to that userMention that usercommented on by that userLearn more aboutinvolveshere.User Reviewedprfiestaexposes a--use-reviewed-byflag which will collect pull requests where the userhas reviewedother's pull requests.Learn more about searching review requestshereUser Requested Reviewprfiestaexposes a--use-review-requestedflag which will collect pull requests where the user wasrequesteda review from other collaborators.Learn more about searching review requestshereDate FilterWhen using the--afterand--beforedate filters, by defaultprfiestawill use thecreateddate dimension with these filters on the Git provider (e.g GitHub). This may not fit your use case and you may want to filter on when a pull request wasupdatedinstead. To do this you can use the--use-updatedflag.Learn more about date filtershere.Reference SearchYou may come across a use case where you want to filter pull requests on a specific reference. For example, it may be a team practise to put a JIRA card reference within the pull request title or body.For this you can use the--referencefilter.[!NOTE]
Results from reference search is entirely up to the GitHub Search API. On some ocassions, it may not provide inaccurate results.Analysisprfiestaships with built in plots to help analyze your pull request data. These serve as a starting point in your analysis. See more information on the build in plots and viewshere.Using GitHub EnterpriseIf you trying to fetch data from aGitHub Enterpriseserver, then much of the same functionality should work the same. You just need to make sure that:GH_HOSTis set to your enterprise instance's API URL. Reach out to your internal GitHub team if you are not sure what this should be.GITHUB_ENTERPRISE_TOKENapersonal access tokengenerated on your GitHub Enterprise instance.GitHub Rate LimitingDepending on your input parameters, you may end up in a situation where you are beingRate Limitedby the GitHub API.See thisNotebookon a way to handle this.Environment VariablesVariableDescriptionDefaultGITHUB_TOKENThe GithubTokento useGITHUB_ENTERPRISE_TOKENTakes precedence overGITHUB_TOKENwhen setGH_HOSTThe Github Host to communicate with (Override this with your company's GitHub Enterprise server if needed)https://api.github.comLOGGING_LEVELTheLogging Levelto useINFOLOGGING_FORMATTheLogging Formatto use%(message)sSPINNER_STYLETheSpinner Styleto useblueDeveloper SetupAssuming you have cloned the repository and are at the root of the repository in your terminal.poetryshell
poetryinstall
poetrybuildThis should leave you in a state where you have the virtual environment sourced, all dependencies are installed andprfiestais installed locally.You can then leverage the various commands in themakefilefor development tasks:# Run all unit testsmaketest# Produce code coverage reportsmakecoverage# Code lintingmakelintOptionally you can also installpre-committo run some sanity checks before your commits.# Install it into your git hooks (one time setup)# from this point onwards, any commits will run pre-commit checksprecommit_install# If you want to run all checks on all files without comitting.precommit_runCreating PrereleasesWhen you create a pull request on this repository, various CI checks are run, towards the end of those checks there is areleasejob.Usually when running undermain, this job is responsible for publishing new versions to pypi. However when running under a pull request, this will create a special prerelease package specific to that pull request.The versioning of this package followsPEP-440and will look something like this:0.8.1b125Where0.8.1= The bumped version of what is currently within thepyproject.tomlof that pull request. We don't attempt to do any analysis to figure out if we should be bumping with a higher serverity in this context.b= Beta; Indicates to pypi that this is a prerelease package.125= Thegithub.run_numberfromGitHub Actions.An example prerelease package looks like this:https://pypi.org/project/prfiesta/0.8.1b125/Downstream users can then do a full end to end test with the prerelease package before the change is merged intomain. This will automatically be posted into the pull requestexample.You can find the full version history of packagehere