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

campaigns: Support changeset filtering #8848

Merged
merged 39 commits into from Mar 12, 2020
Merged

campaigns: Support changeset filtering #8848

merged 39 commits into from Mar 12, 2020

Conversation

ryanslade
Copy link
Contributor

@ryanslade ryanslade commented Mar 6, 2020

This adds support for filtering by State, ReviewState and CheckState

The columns are updated when we sync or receive a webhook as these are the moment we get input about external state.

We may need to add a new enum value, UNKNOWN to each of the GraphQL enums so that we can filter to display those states.

The migration adds new columns and types but leaves state as UNKNOWN until next sync or webhook. I think this is fine considering we don't have any customers with large numbers of changesets.

I'll update the resolvers to use the new columns in another PR.

Part of: #8462

@ryanslade ryanslade marked this pull request as ready for review March 6, 2020 12:01
@ryanslade ryanslade requested a review from slimsag as a code owner March 6, 2020 12:01
@ryanslade ryanslade requested review from a team March 6, 2020 12:01
@codecov
Copy link

codecov bot commented Mar 6, 2020

Codecov Report

Merging #8848 into master will decrease coverage by 0.01%.
The diff coverage is 44.94%.

@@            Coverage Diff             @@
##           master    #8848      +/-   ##
==========================================
- Coverage   41.63%   41.62%   -0.02%     
==========================================
  Files        1314     1314              
  Lines       70680    70822     +142     
  Branches     6554     6556       +2     
==========================================
+ Hits        29425    29477      +52     
- Misses      38577    38656      +79     
- Partials     2678     2689      +11
Impacted Files Coverage Δ
web/src/enterprise/campaigns/detail/backend.ts 10.9% <ø> (ø) ⬆️
...b/src/enterprise/campaigns/detail/CampaignTabs.tsx 72.22% <ø> (ø) ⬆️
...rprise/campaigns/detail/changesets/presentation.ts 100% <ø> (ø) ⬆️
enterprise/internal/campaigns/service.go 35.41% <0%> (-0.25%) ⬇️
cmd/frontend/graphqlbackend/campaigns.go 0% <0%> (ø) ⬆️
...rc/enterprise/campaigns/detail/CampaignDetails.tsx 52.28% <0%> (ø) ⬆️
...erprise/internal/campaigns/resolvers/changesets.go 58.74% <100%> (+1.27%) ⬆️
enterprise/internal/campaigns/syncer.go 68.46% <100%> (+0.24%) ⬆️
...nterprise/internal/campaigns/resolvers/resolver.go 36.96% <11.11%> (-1.48%) ⬇️
enterprise/internal/campaigns/webhooks.go 22.22% <60%> (+0.69%) ⬆️
... and 4 more

Copy link
Contributor

@mrnugget mrnugget left a comment

Choose a reason for hiding this comment

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

Happy to see that updating the state based on syncing data and webhook events is as easy as this.

Couple of thoughts:

  • I don't think we should use enums in the database for this. Especially not if we use a bail-out value like UNKNOWN. I would simply use a nullable text column and make sure we handle the null value properly.
  • If we could get away without using UNKNOWN, that would be great. ChangesetReviewStatePending is already a good default value. As is ChangesetStateOpen for State().
  • Can we already use these values in the State(), ReviewState(), CheckState() methods on ChangesetResolver?

cmd/frontend/graphqlbackend/campaigns.go Outdated Show resolved Hide resolved
enterprise/internal/campaigns/store.go Outdated Show resolved Hide resolved
enterprise/internal/campaigns/store.go Outdated Show resolved Hide resolved
enterprise/internal/campaigns/store.go Outdated Show resolved Hide resolved
enterprise/internal/campaigns/syncer.go Outdated Show resolved Hide resolved
enterprise/internal/campaigns/webhooks.go Outdated Show resolved Hide resolved
enterprise/internal/campaigns/syncer.go Outdated Show resolved Hide resolved
enterprise/internal/campaigns/syncer.go Outdated Show resolved Hide resolved
@ryanslade ryanslade requested a review from a team March 10, 2020 16:03
@eseliger
Copy link
Member

image

@ryanslade
Copy link
Contributor Author

Currently our GraphQL and code enums do not match up

# The state of a Changeset Review
enum ChangesetReviewState {
    APPROVED
    CHANGES_REQUESTED
    PENDING
}

# The state of continuous integration checks on a changeset
enum ChangesetCheckState {
    PENDING
    PASSED
    FAILED
}
// ChangesetReviewState constants.
const (
	ChangesetReviewStateApproved         ChangesetReviewState = "APPROVED"
	ChangesetReviewStateChangesRequested ChangesetReviewState = "CHANGES_REQUESTED"
	ChangesetReviewStatePending          ChangesetReviewState = "PENDING"
	ChangesetReviewStateCommented        ChangesetReviewState = "COMMENTED"
	ChangesetReviewStateDismissed        ChangesetReviewState = "DISMISSED"
)

// ChangesetCheckState constants.
type ChangesetCheckState string

const (
	ChangesetCheckStateUnknown ChangesetCheckState = "UNKNOWN"
	ChangesetCheckStatePending ChangesetCheckState = "PENDING"
	ChangesetCheckStatePassed  ChangesetCheckState = "PASSED"
	ChangesetCheckStateFailed  ChangesetCheckState = "FAILED"
)

For CheckState if our Go type is UNKNOWN we return nil to the API. Do we want to allow filtering to UNKNOWN check states?

Review state currently works since we don't currently return any values that don't exist in the GraphQL API but it does make me a bit nervous that it could break in future.

@eseliger @mrnugget Thoughts?

@ryanslade
Copy link
Contributor Author

I had an idea for how to handle review state. Once all the logic of computing state is moved to update time then the code at the resolver layer will just be reading the value from a field and we can decide at that point what to do with values that don't exist in graohql. At least then that logic is isolated to the resolver layer. It's still not totally type safe but I think it's more explicit that what's happening now

@ryanslade
Copy link
Contributor Author

PTAL

@mrnugget I'll do the resolver changes in another PR as this one is already pretty big

cmd/frontend/graphqlbackend/schema.graphql Show resolved Hide resolved
enterprise/internal/campaigns/webhooks.go Outdated Show resolved Hide resolved
internal/campaigns/types.go Outdated Show resolved Hide resolved
internal/campaigns/types.go Show resolved Hide resolved
enterprise/internal/campaigns/store.go Show resolved Hide resolved
enterprise/internal/campaigns/syncer.go Outdated Show resolved Hide resolved
enterprise/internal/campaigns/syncer.go Outdated Show resolved Hide resolved
@mrnugget
Copy link
Contributor

Ah, sorry, I had "Approve" selected but meant: changes requested. Take a look at the comments.

@mrnugget
Copy link
Contributor

If I understand it correctly: the UI in here completes this feature, right? If so, please add a changelog entry :)

Copy link
Contributor

@mrnugget mrnugget left a comment

Choose a reason for hiding this comment

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

Approving. Discussed comments etc. on Slack call.

internal/campaigns/types.go Outdated Show resolved Hide resolved
internal/campaigns/types.go Outdated Show resolved Hide resolved
enterprise/internal/campaigns/service.go Show resolved Hide resolved
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.

None yet

3 participants