Skip to content

Initial commit of the collect_signals command. #120

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

Merged
merged 12 commits into from
May 26, 2022
Merged

Initial commit of the collect_signals command. #120

merged 12 commits into from
May 26, 2022

Conversation

calebbrown
Copy link
Contributor

@calebbrown calebbrown commented May 20, 2022

  • defines key APIs:
    • projectrepo.Repo and projectrepo.Factory
    • signal.Set and signal.Signal
    • collector.Collector and collector.Registry
  • implements the complete current set of signals for GitHub repos.
  • supports CSV output.
  • refactors GitHub API related code into an internal package for reuse.
  • requires Go 1.18 for fancy features like generics and any
  • clarified the field types in the milestone 1 doc, particularly around nullness and date/time formats.

Not yet there:

  • documentation needs extending
  • cmd/collect_signals/github/queries.go is a bit of a mess
  • more unit tests

- defines key APIs:
  - projectrepo.Repo and projectrepo.Factory
  - signal.Set and signal.Signal
  - collector.Collector and collector.Registry
- implements the complete current set of signals for GitHub repos.
- supports CSV output.
- refactors GitHub API related code into an internal package for reuse.
@calebbrown calebbrown requested a review from oliverchang May 20, 2022 04:40
@calebbrown
Copy link
Contributor Author

Sorry for the huge commit.

Copy link
Member

@naveensrinivasan naveensrinivasan left a comment

Choose a reason for hiding this comment

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

Thank you!

"github.com/shurcooL/githubv4"
)

type Client struct {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback, interfaces certainly help with testability and I do need to do some work in this area.

At the moment I can mock the HTTP libraries, but that may not be the most practical approach.

I expect this area to evolve significantly over the next few months.

Copy link
Contributor

@oliverchang oliverchang left a comment

Choose a reason for hiding this comment

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

some initial comments! still trying to digest the other bits (especially the generics/signal.Set parts).

Copy link
Contributor

@oliverchang oliverchang left a comment

Choose a reason for hiding this comment

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

LGTM with remaining comments addressed. Thanks!

if comments, err := legacy.FetchIssueCommentCount(ctx, ghr.client, ghr.owner(), ghr.name(), legacy.IssueLookback); err != nil {
if errors.Is(err, legacy.TooManyResultsError) {
ghr.logger.Debug("Comment count failed with too many result")
s.CommentFrequency.Set(2.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: put 2.0 in a constant to make it clear this is the default?

Also, why 2.0 as the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

2.0 was roughly what I was seeing on repos (usually between 1.5 and 2.5) for comment frequency.

It is a bit of a magic value, and leaving it unset may be more accurate.

Copy link
Contributor

Choose a reason for hiding this comment

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

ack.

cs, resp, err := c.Rest().Issues.ListComments(ctx, owner, name, 0, opts)
// The API returns 5xx responses if there are too many comments.
if c := githubapi.ErrorResponseStatusCode(err); 500 <= c && c < 600 {
return 0, TooManyResultsError
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems inconsistent with the other implementations' behaviour (e.g. contributor count), which seems to hide this detail from the caller and just return the maximum number.

i.e.

	cs, resp, err := c.Rest().Repositories.ListContributors(ctx, owner, name, opts)
	if errorTooManyContributors(err) {
		return MaxContributorLimit, nil
	}

Would that make more sense here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not a huge fan of this difference, but it currently exists this way due to the usage of the results from FetchIssueCount() to generate the frequency (i.e. average comments per issue).

I have an refactoring in mind to improve the API around a struct{} that could also be used to reduce the number of args to the methods and provide some caching - making it possible to move this into a more logical location.

For the time being I'd be happy to get this merged and do some future refactoring soon (I've added a TODO).

Copy link
Contributor

Choose a reason for hiding this comment

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

ack.

@calebbrown calebbrown merged commit 678f3d3 into main May 26, 2022
@calebbrown calebbrown deleted the milestone1 branch May 26, 2022 23:17
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.

3 participants