def test_read_json_file(self): """ Test whether read_json_file correctly reads a file of Perceval data, where each line in the file is of json format. """ expected = read_file('data/test_commits_data.json') items = read_json_file('data/test_commits_data.json') self.assertEqual(expected, items)
the plot. """ title = "Trends in Commits Made" x = None y = 'count' use_index = True return {'x': x, 'y': y, 'title': title, 'use_index': use_index} def __str__(self): return "Code Changes" if __name__ == "__main__": date_since = datetime.strptime("2018-09-07", "%Y-%m-%d") items = read_json_file('../git-commits.json') # total changes changes = CodeChangesGit(items, date_range=(date_since, None)) print("Code_Changes, total:", changes.compute()) # excluding certain files changes = CodeChangesGit(items, date_range=(date_since, None), is_code=[DirExclude(['tests']), PostfixExclude(['.md', 'COPYING'])]) print("Code_Changes, excluding some files:", changes.compute()) # considering commits only on the master changes = CodeChangesGit(items, date_range=(date_since, None), conds=[MasterInclude()]) print("Code_Changes, only for master:", changes.compute())
the plot. """ title = "Trends in Open Issue Age" x = None y = 'mean' use_index = True return {'x': x, 'y': y, 'title': title, 'use_index': use_index} def __str__(self): return "Open Issue Age" if __name__ == "__main__": date_since = datetime.strptime("2018-09-07", "%Y-%m-%d") items = read_json_file('../issues.json') # the GitHub API considers all pull requests to be issues. Any # pull request represented as an issue has a 'pull_request' # attribute, which is used to filter them out from the issue # data. items = [item for item in items if 'pull_request' not in item['data']] # total number of open issues in a given period open_issue_age = OpenIssueAgeGitHub(items) print("The average age of all open issues is {:.2f}" .format(open_issue_age.compute())) # number of open issues created after a certain date open_issue_age = OpenIssueAgeGitHub(items, (date_since, None))
the plot. """ title = "Trends in Reviews Declined" x = None y = 'count' use_index = True return {'x': x, 'y': y, 'title': title, 'use_index': use_index} def __str__(self): return "Reviews Declined" if __name__ == "__main__": date_since = datetime.strptime("2018-09-07", "%Y-%m-%d") items = read_json_file('../pull_requests.json') # total number of reviews declined reviews_declined = ReviewsDeclinedGitHub(items) print("The total number of reviews declined is {}".format( reviews_declined.compute())) # number of reviews declined after a certain date reviews_declined = ReviewsDeclinedGitHub(items, (date_since, None)) print("The number of reviews created after 2018-09-07" "which were declined is {}".format(reviews_declined.compute())) # time-series on a monthly basis for the number of reviews declined print("The trends in the number of declined reviews, created" " from 2018-09-07 onwards, are: ") print(reviews_declined.time_series('M'))
the plot. """ title = "Trends in Issues Opened" x = None y = 'count' use_index = True return {'x': x, 'y': y, 'title': title, 'use_index': use_index} def __str__(self): return "Issues New" if __name__ == "__main__": date_since = datetime.strptime("2018-09-07", "%Y-%m-%d") items = read_json_file('../issues_events.json') # the GitHub API considers all pull requests to be issues. Any # pull request represented as an issue has a 'pull_request' # attribute, which is used to filter them out from the issue # data. items = [item for item in items if 'pull_request' not in item['data']] # total new issues new_issues = IssuesNewGitHub(items, reopen_as_new=False) print("The total number of new issues is {:.2f}".format( new_issues.compute())) # new issues created after a certain date new_issues = IssuesNewGitHub(items, (date_since, None), reopen_as_new=True)