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

324 GitHub discussions with graph ql api #332

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
287f95b
i #230 generalized get functions
anthonyjlau Mar 23, 2024
6c323ce
i #230 added new get functions
anthonyjlau Mar 26, 2024
ffb969a
i #230 changed functions that access lists
anthonyjlau Mar 28, 2024
a7b719f
i #230 updated comments, added catches
anthonyjlau Mar 28, 2024
a16ab10
i #230 updated jira and mbox funcs to rtn a list
anthonyjlau Apr 3, 2024
f249709
i #230 added the project_key_index for Jira
anthonyjlau Apr 10, 2024
f6e8e31
i #230 added function to return GitHub keys
anthonyjlau Apr 10, 2024
42fee34
i #288 added changes to github, mail structure
anthonyjlau Apr 28, 2024
b1e4001
fix github checks
carlosparadis Apr 28, 2024
1b1535b
fixes compiling error
carlosparadis Apr 28, 2024
f160003
i #230 added config file changes
anthonyjlau Apr 29, 2024
ba27309
Merge branch 'master' into 230-abstract-config-file-parsing
carlosparadis Apr 29, 2024
4fe896d
Documentation edit for PR reflection test.
beydlern Sep 11, 2024
720c028
Minor Documentation Edit for PR Reflection Test
crepesAlot Sep 12, 2024
ef42bd3
i #230 replace a notebook's paths to get functions
beydlern Sep 20, 2024
c15223c
i #230 removed source call from modified notebook
beydlern Sep 20, 2024
b8d482b
i #230 removed incorrect pathing in config.R
beydlern Sep 24, 2024
f9d20ec
i #230 redefined get functions and updated an .Rmd
beydlern Sep 25, 2024
cccb8ef
i #230 Fix config.R Function Descriptions and Implement Notebooks
beydlern Sep 29, 2024
1219265
i #230 Update and Refactor Conf/ Files
crepesAlot Oct 2, 2024
3202887
Merge branch '230-abstract-config-file-parsing' of https://github.com…
crepesAlot Oct 2, 2024
fda90ae
i #230 Refactored More Notebooks
beydlern Oct 3, 2024
df129df
i #230 Corrected config.R Documentation
beydlern Oct 5, 2024
85f4830
i #230 Organized config.R functions
crepesAlot Oct 9, 2024
cee5e36
i #230 Removed Unused Getters
beydlern Oct 9, 2024
25deb91
i #230 Bugzilla Getters
beydlern Oct 9, 2024
89e768f
i #230 Pipermail Getters
beydlern Oct 10, 2024
cad5c6f
i #230 Mbox and Pipermail Input Getters
beydlern Oct 10, 2024
719650a
i #230 Updated conf/ files
crepesAlot Oct 10, 2024
e352aee
i #230 Understand Tool Getters
beydlern Oct 10, 2024
dbe66c1
Merge branch 'master' into 230-abstract-config-file-parsing
beydlern Oct 10, 2024
15b5e62
i #230 Update NEWS.md
crepesAlot Oct 11, 2024
86bb74b
i #230 Fixed Relative Paths in Notebooks
beydlern Oct 18, 2024
da96766
i #324 Implemented GraphQL functions
crepesAlot Nov 8, 2024
9c8dad9
i #324 Updated downloader function
crepesAlot Nov 13, 2024
2dd8877
i #324 Created refresher function for discussions
crepesAlot Nov 21, 2024
db8a9e3
i #321 Added function to create folder directory to config.R
crepesAlot Nov 21, 2024
20e626d
i #321 Updated function documentation
crepesAlot Nov 21, 2024
50653a0
i #324 Updated Notebook
crepesAlot Dec 5, 2024
a17a482
Merge branch '321-creating-a-file-directory-with-functions-in-configr…
crepesAlot Dec 5, 2024
f4a337f
i #324 Updated Configuration Files
crepesAlot Dec 5, 2024
a6e25cc
i #324 Updated Notebooks
crepesAlot Dec 8, 2024
8e5f5d5
i #324 Deleted refresh function
crepesAlot Dec 11, 2024
2e1b477
i #324 Re-added refresh function
crepesAlot Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ export(get_filter_commit_size)
export(get_git_branches)
export(get_git_repo_path)
export(get_github_commit_path)
export(get_github_discussions_path)
export(get_github_issue_event_path)
export(get_github_issue_or_pr_comment_path)
export(get_github_issue_path)
@@ -109,6 +110,7 @@ export(git_head)
export(git_init)
export(git_log)
export(git_mv)
export(github_api_discussions)
export(github_api_iterate_pages)
export(github_api_page_first)
export(github_api_page_last)
@@ -126,6 +128,8 @@ export(github_api_project_issue_refresh)
export(github_api_project_issue_search)
export(github_api_project_pull_request)
export(github_api_rate_limit)
export(github_parse_discussion_comments)
export(github_parse_discussions)
export(github_parse_project_commits)
export(github_parse_project_issue)
export(github_parse_project_issue_events)
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ __kaiaulu 0.0.0.9700 (in development)__

### NEW FEATURES

* `config.R` now contains a set of getter functions used to centralize the gathering of configuration data and these getter functions are used to refactor configuration file information gathering. For example, loading configuration file information with variable assignment is as follows `git_repo_path <- config_file[["version_control"]][["log"]]` but refactoring with a config.R getter function becomes `git_repo_path <- get_git_repo_path(config_file)`. [#230](https://github.com/sailuh/kaiaulu/issues/230)
* The GitHUB API has been expanded to use refresh, along with other functions. `github_api_project_issue_search` has been added that makes the search/issues endpoint API calls. `github_api_project_issue_or_pr_comments_by_date` and `github_api_project_issue_by_date` have been added to download issue data and comments by date ranges. `github_parse_search_issues_refresh` has been added that parses the issue data downloaded from the search endpoint in the refresh_issues folder. `github_api_project_issue_refresh` and `github_api_project_issue_or_pr_comment_refresh` were added to download issue data or comments respectively that have not already been downloaded. `format_created_at_from_file` was added to retrieve the greatest date from a JSON file. See the Reference Docs on GitHub section for more details. [#282](https://github.com/sailuh/kaiaulu/issues/282)
* `config.R` now contains a set of getter functions used to centralize the gathering of configuration data and these getter functions are used to refactor configuration file information gathering. For example, loading configuration file information with variable assignment is as follows `git_repo_path <- config_file[["version_control"]][["log"]]` but refactoring with a config.R getter function becomes `git_repo_path <- get_git_repo_path(config_file)`. [#230](https://github.com/sailuh/kaiaulu/issues/230)
* `refresh_jira_issues()` had been added. It is a wrapper function for the previous downloader and downloads only issues greater than the greatest key already downloaded. [#275](https://github.com/sailuh/kaiaulu/issues/275)
194 changes: 194 additions & 0 deletions R/config.R
Original file line number Diff line number Diff line change
@@ -29,6 +29,176 @@ parse_config <- function(config_path) {
return(conf)
}

##### File Directory Function #####

#' Creates file directories needed by the configuration file (.yml).
#'
#' @description The input is the parsed config file that the user will be using.
#' It will take the parsed config to get the filepaths that need to be created to
#' use the config file. The function relies on the helper function `create_file_directory`
#' to see if any of the directories already exist, and create those that don't.
#'
#' @param config The parsed config file the function is creating the directory for.
#' @param verbose A boolean variable that prints operational messages when set to TRUE.
#' Obtained from `parse_config` function.
#' @export
create_file_directory <- function(conf, verbose= FALSE) {
# Create the git_repo folder
create_file_path(conf[["version_control"]][["log"]])

# Create the mailing_list directory, if needed
if (!is.null(conf[["mailing_list"]])) {
# Check if there is mod_mbox
if (!is.null(conf[["mailing_list"]][["mod_mbox"]])) {
# Create for each project key
project_keys <- names(conf[["mailing_list"]][["mod_mbox"]])
for (key in project_keys) {
mailing_list <- conf[["mailing_list"]][["mod_mbox"]][[key]]
create_file_path(mailing_list[["save_folder_path"]])
}
} else {
if (verbose) {
message("No mod_mbox found")
}
}
# Check if there is pipermail
if (!is.null(conf[["mailing_list"]][["pipermail"]])) {
# Create for each project key
project_keys <- names(conf[["mailing_list"]][["pipermail"]])
for (key in project_keys) {
mailing_list <- conf[["mailing_list"]][["pipermail"]][[key]]
create_file_path(mailing_list[["save_folder_path"]])
}
} else {
if (verbose) {
message("No pipermail found")
}
}
} else {
if (verbose) {
message("No mailing_list found")
}
}

# Create the issue_tracker directory, if needed
if (!is.null(conf[["issue_tracker"]])) {
# Check for jira
if (!is.null(conf[["issue_tracker"]][["jira"]])) {
# Create for each project key
project_keys <- names(conf[["issue_tracker"]][["jira"]])
for (key in project_keys) {
issue_tracker <- conf[["issue_tracker"]][["jira"]][[key]]
create_file_path(issue_tracker[["issues"]])
create_file_path(issue_tracker[["issue_comments"]])
}
} else {
if (verbose) {
message("No jira found")
}
}
# Check for github
if (!is.null(conf[["issue_tracker"]][["github"]])) {
# Create for each project key
project_keys <- names(conf[["issue_tracker"]][["github"]])
for (key in project_keys) {
issue_tracker <- conf[["issue_tracker"]][["github"]][[key]]
create_file_path(issue_tracker[["issue_or_pr_comment"]])
create_file_path(issue_tracker[["issue"]])
create_file_path(issue_tracker[["issue_search"]])
create_file_path(issue_tracker[["issue_event"]])
create_file_path(issue_tracker[["pull_request"]])
create_file_path(issue_tracker[["commit"]])
create_file_path(issue_tracker[["discussion"]])
}
} else {
if (verbose) {
message("No github found")
}
}
# Check for bugzilla
if (!is.null(conf[["issue_tracker"]][["bugzilla"]])) {
# Create for each project key
project_keys <- names(conf[["issue_tracker"]][["bugzilla"]])
for (key in project_keys) {
issue_tracker <- conf[["issue_tracker"]][["bugzilla"]][[key]]
create_file_path(issue_tracker[["issues"]])
create_file_path(issue_tracker[["issue_comments"]])
}
} else {
if (verbose) {
message("No bugzilla found")
}
}
} else {
if (verbose) {
message("No issue_tracker found")
}
}

# Create the tools directory, if needed
if (!is.null(conf[["tool"]])) {
# Check for dv8
if (!is.null(conf[["tool"]][["dv8"]])) {
create_file_path(conf[["tool"]][["dv8"]][["folder_path"]])
} else {
if (verbose) {
message("dv8 is unused")
}
}
# Check for srcml
if (!is.null(conf[["tool"]][["srcml"]])) {
create_file_path(conf[["tool"]][["srcml"]][["srcml_path"]])
} else {
if (verbose) {
message("srcml is unused")
}
}
# Check for pattern4
if (!is.null(conf[["tool"]][["pattern4"]])) {
create_file_path(conf[["tool"]][["pattern4"]][["class_folder_path"]])
create_file_path(conf[["tool"]][["pattern4"]][["output_filepath"]])
} else {
if (verbose) {
message("pattern4 is unused")
}
}
# Check for understand
if (!is.null(conf[["tool"]][["understand"]])) {
create_file_path(conf[["tool"]][["understand"]][["project_path"]])
create_file_path(conf[["tool"]][["understand"]][["output_path"]])
}
} else {
if (verbose) {
message("no tools used")
}
}
}

#' A helper function for `create_file_directory`.
#'
#' @description The function checks if a filepath exists on the local device.
#' If the filepath does not exist, then the function creates it.
#'
#' @param filepath The filepath to create.
#' @param verbose A boolean variable that prints the operational messages when set to TRUE.
#' @export
create_file_path <- function(filepath, verbose= TRUE) {
if (!is.null(filepath)) {
# Check if the filepath doesn't exists
if (!dir.exists(filepath)) {
# Create the filepath
dir.create(filepath, recursive= TRUE)
if (verbose) {
message("Created filepath: ", filepath)
}
}
} else {
if (verbose) {
message("Invalid filepath: ", filepath)
}
}
}

##### Git Getter Functions #####

#' Returns the path to the .git of the project repository that is being analyzed.
@@ -579,6 +749,30 @@ get_github_commit_path <- function(config_file, project_key_index) {
return(commit_path)
}

#' Returns the local folder path for Github Discussions for a specific project key.
#'
#' @description This function returns the local folder path for GitHub discussions
#' for a specific project key, that is specified in the input
#' parameter `config_file`. The input, `config_file` must be a parsed
#' configuration file. The function will inform the user if the local folder
#' path for the discussions exists in the parsed configuration file,
#' `config_file`.
#'
#' @param config_file The parsed configuration file obtained from \code{\link{parse_config}}.
#' @param project_key_index The name of the index of the project key (e.g. "project_key_1" or "project_key_2").
#' @return The local folder path for GitHub Discussions for project specified by key `project_key_index`.
#' @export
get_github_discussions_path <- function(config_file, project_key_index) {

discussion_path <- config_file[["issue_tracker"]][["github"]][[project_key_index]][["discussion"]]

if (is.null(discussion_path)) {
warning("Attribute does not exist in the configuration file.")
}

return(discussion_path)
}

### Bugzilla Functions #####

#' Returns the name of the Bugzilla project key for a specific project key index.
Loading