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

Getting GitHub Metrics #10

Merged
merged 54 commits into from
Nov 21, 2023
Merged

Getting GitHub Metrics #10

merged 54 commits into from
Nov 21, 2023

Conversation

cansavvy
Copy link
Collaborator

@cansavvy cansavvy commented Nov 11, 2023

Summary

Collecting all the metrics we might want from GitHub. Basically this summarizes to

authorize("github")
# You can collect all the metrics for all the repos for an organization
all_repos_metrics <- get_repos_metrics(owner = "fhdsl")

# Or you can provide a list of repos that you want metrics for
repo_names <- c("fhdsl/metricminer", "jhudsl/OTTR_Template")
some_repos_metrics <- get_repos_metrics(repo_names = repo_names)

There's also some creds handling improvements here.

Caveat

The metrics bit only reports the last two weeks. This is just a thing GitHub does that isn't great. So we will be able to have more than just two weeks of metrics but only after we start collecting and storing.

@cansavvy cansavvy changed the base branch from main to cansavvy/polishing_auth November 11, 2023 03:23
R/auth.R Show resolved Hide resolved
@cansavvy
Copy link
Collaborator Author

Looks like the metrics for this are limited to a 2 week span https://github.com/orgs/community/discussions/15189 womp womp. So we scraping here I come.

Base automatically changed from cansavvy/polishing_auth to main November 15, 2023 13:15
@cansavvy
Copy link
Collaborator Author

Looks like the metrics for this are limited to a 2 week span https://github.com/orgs/community/discussions/15189 womp womp. So we scraping here I come.

Webscraping will still happen. But it will not address this issue. ☹️

@cansavvy cansavvy marked this pull request as ready for review November 15, 2023 14:59
R/cran.R Show resolved Hide resolved
R/github.R Show resolved Hide resolved
R/github.R Show resolved Hide resolved
Copy link
Contributor

@howardbaik howardbaik left a comment

Choose a reason for hiding this comment

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

get_github_metrics() is buggy, as described in my inline comments. I can take a look at what's causing the error.

I created a sub-branch of cansavvy/github called howardbaek/github-fix. I'll be working on that branch, and request a PR that merges my changes into cansavvy/github

R/auth.R Show resolved Hide resolved
R/auth.R Outdated Show resolved Hide resolved
R/auth.R Outdated Show resolved Hide resolved
R/github.R Outdated Show resolved Hide resolved
R/github.R Outdated Show resolved Hide resolved
R/github.R Outdated Show resolved Hide resolved
R/github.R Outdated Show resolved Hide resolved
R/github.R Outdated Show resolved Hide resolved
R/github.R Outdated Show resolved Hide resolved
@howardbaik
Copy link
Contributor

howardbaik commented Nov 20, 2023

Now, I'm getting this error message from running metrics <- get_github_metrics(repo = "fhdsl/metricminer")

Error in lapply(repo_metric_list$contributors, function(contributor) { : 
  could not find function "%>%"

I'm getting the same error message when running all_repos_metrics <- get_repos_metrics(owner = "fhdsl") because get_github_metrics() is inside get_repos_metrics()

message("Cached Google .httr-oauth file deleted")
if (app_name == "all" | app_name == "github") {
if (github_creds_exist) {
options(github_api = NULL)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll need to DRY up some of this auth section in a future PR

@cansavvy cansavvy mentioned this pull request Nov 21, 2023
@cansavvy
Copy link
Collaborator Author

cansavvy commented Nov 21, 2023

I think this PR has gotten unwieldy.

So my general strategy at this point is to:

  1. Merge this when we feel "decent enough" about it; meaning @howardbaek is able to get the data he needs to start working on the dashboard: This means, you'll need to run get_repos_metrics() but just for ITCR relevant repositories. Meaning OTTR ones, this one, and probably all course PRs. (But again, maybe focus on building the dashboard page for Google Analytics first if that data collecting is working for you.)
  2. Then I will start working on unit testing UNIT TESTING #8 so that we can try to avoid unwieldy PRs like this in the future.
  3. From there we can document bugs and file smaller PRs for the rest.

Sound good @howardbaek ?

@cansavvy
Copy link
Collaborator Author

I believe a majority of the bugs are fixed (until we find more when I build unit testing). @howardbaek Can you just test using:

devtools::load_all()
repo_names <- c("fhdsl/metricminer", "jhudsl/OTTR_Template")
some_repos_metrics <- get_repos_metrics(repo_names = repo_names)

And see if this works for you? if so then I think it would be easiest to merge this and go from there

@howardbaik
Copy link
Contributor

some_repos_metrics <- get_repos_metrics(repo_names = repo_names)

That code chunk works on my end, but some_repos_metrics is a data frame with unnecessary rownames that are the same values as the repo_name column. What do you think of outputting a tibble using as_tibble()?

@cansavvy
Copy link
Collaborator Author

some_repos_metrics <- get_repos_metrics(repo_names = repo_names)

That code chunk works on my end, but some_repos_metrics is a data frame with unnecessary rownames that are the same values as the repo_name column. What do you think of outputting a tibble using as_tibble()?

Yeah I'm okay with tibbles or data frames. We can further discuss this data's format for future PRs but lets get this in for now

@cansavvy cansavvy merged commit af0bed8 into main Nov 21, 2023
5 checks passed
@cansavvy cansavvy deleted the cansavvy/github branch November 21, 2023 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants