-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from firstcontributions/related_issues
Added relevant issues for stories
- Loading branch information
Showing
8 changed files
with
174 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
internal/graphql/schema/storyissues_from_reposqueryresolver.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package schema | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/firstcontributions/backend/internal/models/issuesstore" | ||
"github.com/firstcontributions/backend/internal/storemanager" | ||
) | ||
|
||
type StoryIssuesFromReposInput struct { | ||
First *int32 | ||
Last *int32 | ||
After *string | ||
Before *string | ||
SortOrder *string | ||
SortBy *string | ||
} | ||
|
||
func (n *Story) IssuesFromRepos(ctx context.Context, in *StoryIssuesFromReposInput) (*IssuesConnection, error) { | ||
var first, last *int64 | ||
if in.First != nil { | ||
tmp := int64(*in.First) | ||
first = &tmp | ||
} | ||
if in.Last != nil { | ||
tmp := int64(*in.Last) | ||
last = &tmp | ||
} | ||
store := storemanager.FromContext(ctx) | ||
issueType := "issues_from_repo_story" | ||
|
||
filters := &issuesstore.IssueFilters{ | ||
IssueType: &issueType, | ||
Story: n.ref, | ||
} | ||
sortByStr := "" | ||
if in.SortBy != nil { | ||
sortByStr = *in.SortBy | ||
} | ||
data, hasNextPage, hasPreviousPage, cursors, err := store.IssuesStore.GetIssues( | ||
ctx, | ||
filters, | ||
in.After, | ||
in.Before, | ||
first, | ||
last, | ||
issuesstore.GetIssueSortByFromString(sortByStr), | ||
in.SortOrder, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return NewIssuesConnection(filters, data, hasNextPage, hasPreviousPage, cursors), nil | ||
} |
54 changes: 54 additions & 0 deletions
54
internal/graphql/schema/storyrelevant_issuesqueryresolver.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package schema | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/firstcontributions/backend/internal/models/issuesstore" | ||
"github.com/firstcontributions/backend/internal/storemanager" | ||
) | ||
|
||
type StoryRelevantIssuesInput struct { | ||
First *int32 | ||
Last *int32 | ||
After *string | ||
Before *string | ||
SortOrder *string | ||
SortBy *string | ||
} | ||
|
||
func (n *Story) RelevantIssues(ctx context.Context, in *StoryRelevantIssuesInput) (*IssuesConnection, error) { | ||
var first, last *int64 | ||
if in.First != nil { | ||
tmp := int64(*in.First) | ||
first = &tmp | ||
} | ||
if in.Last != nil { | ||
tmp := int64(*in.Last) | ||
last = &tmp | ||
} | ||
store := storemanager.FromContext(ctx) | ||
issueType := "relevant_issues_story" | ||
|
||
filters := &issuesstore.IssueFilters{ | ||
IssueType: &issueType, | ||
Story: n.ref, | ||
} | ||
sortByStr := "" | ||
if in.SortBy != nil { | ||
sortByStr = *in.SortBy | ||
} | ||
data, hasNextPage, hasPreviousPage, cursors, err := store.IssuesStore.GetIssues( | ||
ctx, | ||
filters, | ||
in.After, | ||
in.Before, | ||
first, | ||
last, | ||
issuesstore.GetIssueSortByFromString(sortByStr), | ||
in.SortOrder, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return NewIssuesConnection(filters, data, hasNextPage, hasPreviousPage, cursors), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters