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

API for the Aggregator Endpoint #24

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open

Conversation

faktas2
Copy link

@faktas2 faktas2 commented Jun 20, 2022

Hi,

This package currently doesn't support the aggregator endpoint, which is super useful at decreasing the amount of requests that could be made to PivotalTracker.

https://www.pivotaltracker.com/help/api/#Using_the_GET_Request_Aggregator

This PR adds a new service to the package for using the aggregator. It currently only supports getting the stories, comments of stories and reviews of stories. However, if the pattern is approved, I believe the API could be extended to support other parts of PivotalTracker.

Note: It uses some parts from the fork https://github.com/oschwald/go-pivotaltracker.

A sample use would be similar to below,

ptClient := pivotal.NewClient("TOKEN")
storiesToGet := []int{
	1,
	2,
	3,
	4,
}
projectID := 123
aggregation := ptClient.Aggregator.GetBuilder().Stories(projectID, storiesToGet).Story(projectID, 5)
aggregation.CommentsOfStories(projectID, storiesToGet).ReviewsOfStories(projectID, storiesToGet)
aggregation, err := aggregation.Send()
_ = err

story, _ := aggregation.GetStory(projectID, 1)
comments, _ := aggregation.GetComments(projectID, 2)
reviews, _ := aggregation.GetReviews(projectID, 2)
_ = story

Copy link
Contributor

@oschwald oschwald left a comment

Choose a reason for hiding this comment

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

I had a few small comments.

return &AggregatorService{client}
}

// Adds the url for the story to the aggregation data.
Copy link
Contributor

Choose a reason for hiding this comment

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

It is idiomatic to start the documentation with the name of the thing you are documenting , e.g., this might be "Story adds the url for the story to the aggregation data."

Would you be willing to update this for all the public member in this PR?

return a
}

func BuildStoryURLOnlyUsingStoryID(storyID int) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these URL helpers need to be public? I think they would only be used internally.

}

// Sends the request for the aggregation.
func (a *Aggregation) Send() (*Aggregation, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like all of the other equivalent methods in the module return the *http.Response as well, e.g., List(). It'd probably make sense to do that for consistency. I am not sure the exact use case.

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.

4 participants