Added category to StoriesFilter
the build was successful

This commit is contained in:
2018-08-01 14:38:09 +02:00
parent d5df624188
commit 132cf28f0f
3 changed files with 17 additions and 7 deletions
+4 -1
View File
@@ -19,6 +19,7 @@ type StoriesArg struct {
} }
EarliestFictionalDate *string EarliestFictionalDate *string
LatestFictionalDate *string LatestFictionalDate *string
Category *string
Limit *int32 Limit *int32
Open *bool Open *bool
Unlisted *bool Unlisted *bool
@@ -34,6 +35,8 @@ func (r *QueryResolver) Stories(ctx context.Context, args *StoriesArg) ([]*types
author = *filter.Author author = *filter.Author
} }
category := filter.Category
tags := make([]story.Tag, 0, 8) tags := make([]story.Tag, 0, 8)
if filter != nil && filter.Tags != nil { if filter != nil && filter.Tags != nil {
for _, tagInput := range *filter.Tags { for _, tagInput := range *filter.Tags {
@@ -82,7 +85,7 @@ func (r *QueryResolver) Stories(ctx context.Context, args *StoriesArg) ([]*types
limit = int(*filter.Limit) limit = int(*filter.Limit)
} }
stories, err := story.List(author, tags, earliest, latest, unlisted, open, limit) stories, err := story.List(author, category, tags, earliest, latest, unlisted, open, limit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
+8 -5
View File
@@ -40,6 +40,9 @@ input StoriesFilter {
# What author to query for # What author to query for
author: String author: String
# What category to query for
category: StoryCategory
# What tags to query for # What tags to query for
tags: [TagInput!] tags: [TagInput!]
@@ -131,18 +134,18 @@ input StoryTagRemoveInput {
# Possible values for Story.category # Possible values for Story.category
enum StoryCategory { enum StoryCategory {
# Description and content of a document or item # General information
Document Info
# News stories # News stories
News News
# Description and content of a document or item
Document
# Information about something going on in the background that may or may not inform RP # Information about something going on in the background that may or may not inform RP
Background Background
# General information
Info
# A short story # A short story
Story Story
} }
+5 -1
View File
@@ -193,13 +193,17 @@ func FindID(id string) (Story, error) {
} }
// List lists stories by any non-zero criteria passed with it. // List lists stories by any non-zero criteria passed with it.
func List(author string, tags []Tag, earliest, latest time.Time, unlisted bool, open *bool, limit int) ([]Story, error) { func List(author string, category *string, tags []Tag, earliest, latest time.Time, unlisted bool, open *bool, limit int) ([]Story, error) {
query := bson.M{} query := bson.M{}
if author != "" { if author != "" {
query["author"] = author query["author"] = author
} }
if category != nil {
query["category"] = category
}
if len(tags) > 0 { if len(tags) > 0 {
query["tags"] = bson.M{"$in": tags} query["tags"] = bson.M{"$in": tags}
} }