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

Add functionality for milestones #58

Open
konradmayer opened this issue Nov 17, 2021 · 2 comments
Open

Add functionality for milestones #58

konradmayer opened this issue Nov 17, 2021 · 2 comments

Comments

@konradmayer
Copy link

Thanks a lot for this great package!

This is a feature request for adding functionality for milestones to the package.

Being able to retreive milestones (besides issues) renders very powerful applications for project management possible - e.g. automated creation of Gantt charts using DiagrammeR.

I altereted your gl_list_issues() function for a quick try and it worked flawlessly, so it shouldn't be too much work to implement it as it basically boils down to mimic the issue functions.

gl_list_milestones <- function (project = NULL, milestone_id = NULL, verb = httr::GET, 
          api_version = 4, ...) 
{
  (if (!missing(project) && is.null(project)) 
    "milestones"
    else gl_proj_req(project, req = c("milestones", milestone_id), ...)) %>% 
    gitlab(...) %>% arpr::iffn(is.null(milestone_id), function(milestone) {
      milestone %>% unlist(recursive = TRUE) %>% t() %>% as.data.frame()
    })
}

In case I ever find the time for it I would be more than happy to contribute a PR on this issue, but I cannot give any estimate on when this might be...

@statnmap
Copy link
Member

Thank you.
I think it can be simplified if I understand your need correctly.
Is that correct?

id <- 317

# Use existing API directly
gitlabr::gitlab(
  req = c("projects" , id, "milestones"),
  verb = httr::GET
)

# Create a function to get all milestones
gl_list_milestones <- function(project, ...) {
  gl_proj_req(project, c("milestones"), ...) %>% 
    gitlab(...)
}

all_milestones <- gl_list_milestones(project = 317)

# Get milestones issues
gl_list_issues(project = 317, milestone = all_milestones$title[2])

@konradmayer
Copy link
Author

Wow, thats a fast response!

outlined use case

Yes, this is perfect.

By the way, I didn't realize that milestone information also comes with gl_list_issues(), so to get a dataframe of milestones with assigned issues as a list column one can simply do:

project <- "projectname"
# this excludes milestones without assigned issues
all_issues <- gl_list_issues(project = project)
all_issues  %>% nest(issues = -starts_with("milestone."))

However, this does not include milestones without issues assigned. So, using your approach outlines above a better way to do this looks more or less like this:

gl_list_milestones <- function(project, ...) {
  gl_proj_req(project, c("milestones"), ...) %>%
    gitlab(...)
}

project <- "projectname"
# Get milestones
all_milestones <- gl_list_milestones(project = project) %>%
  setNames(paste0('milestone.', names(.)))
# Get issues
all_issues <- gl_list_issues(project = project)

# Join dataframes and nest by milestone
all_milestones %>%
  full_join(all_issues, by = names(all_milestones)) %>%
  nest(issues = -starts_with("milestone."))

feature request

My main motivation for the feature request, i.e. this issue, was the use case as shown above. However it would be useful to have all the APIs functionality (create, edit,...) available, just as it is the case for issues.

https://docs.gitlab.com/ee/api/milestones.html

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

No branches or pull requests

2 participants