Gisle Aune
6 years ago
10 changed files with 209 additions and 60 deletions
-
23cmd/rpdata-server/main.go
-
4graph2/gqlgen.yml
-
34graph2/queries/log.go
-
8graph2/schema/root.gql
-
97graph2/schema/types/Log.gql
-
0internal/loader/channel.go
-
0internal/loader/character.go
-
0internal/loader/loader.go
-
23model/log/filter.go
-
80model/log/log.go
@ -0,0 +1,34 @@ |
|||||
|
package queries |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"errors" |
||||
|
|
||||
|
"git.aiterp.net/rpdata/api/internal/loader" |
||||
|
"git.aiterp.net/rpdata/api/model/log" |
||||
|
) |
||||
|
|
||||
|
func (r *resolver) Log(ctx context.Context, id string) (log.Log, error) { |
||||
|
return log.FindID(id) |
||||
|
} |
||||
|
|
||||
|
func (r *resolver) Logs(ctx context.Context, filter *log.Filter) ([]log.Log, error) { |
||||
|
logs, err := log.List(filter) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
if len(logs) >= 100 { |
||||
|
loader := loader.FromContext(ctx) |
||||
|
if loader == nil { |
||||
|
return nil, errors.New("no loader") |
||||
|
} |
||||
|
|
||||
|
for _, log := range logs { |
||||
|
loader.PrimeCharacters("id", log.CharacterIDs...) |
||||
|
loader.PrimeChannels("name", log.ChannelName) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return logs, nil |
||||
|
} |
@ -0,0 +1,97 @@ |
|||||
|
# A Log is the "file" of an RP session |
||||
|
type Log { |
||||
|
# A unique identifier for the log. |
||||
|
id: String! |
||||
|
|
||||
|
# A secondary unique identifier for the log. This is a lot shorter and more suitable for storage when |
||||
|
# the link doesn't need to be as expressive. |
||||
|
shortId: String! |
||||
|
|
||||
|
# The date for a log. |
||||
|
date: Date! |
||||
|
|
||||
|
# The channel of a log. |
||||
|
channelName: String! |
||||
|
|
||||
|
# Information about the channel this log is in. |
||||
|
channel: Channel! |
||||
|
|
||||
|
# The session's title. |
||||
|
title: String! |
||||
|
|
||||
|
# The log's event, which is the same as the tags in the previous logbot site. |
||||
|
# Empty string means that it's no event. |
||||
|
event: String! |
||||
|
|
||||
|
# The description of a session, which is empty if unset. |
||||
|
description: String! |
||||
|
|
||||
|
# Whether the log session is open. |
||||
|
open: Boolean! |
||||
|
|
||||
|
# The characters involved in the log file. |
||||
|
characters: [Character!]! |
||||
|
|
||||
|
# The posts of the logfile, which can be filtered by kinds. |
||||
|
posts(kinds:[String!]): [Post!]! |
||||
|
} |
||||
|
|
||||
|
# Filter for logs query |
||||
|
input LogsFilter { |
||||
|
# Channels to limit results to (inclusive) |
||||
|
channels: [String!] |
||||
|
|
||||
|
# Events to limit results to (inclusive) |
||||
|
events: [String!] |
||||
|
|
||||
|
# Characters to limit results to (exclusive) |
||||
|
characters: [String!] |
||||
|
|
||||
|
# Search post content |
||||
|
search: String |
||||
|
|
||||
|
# Limit by whether it's open or not |
||||
|
open: Boolean |
||||
|
|
||||
|
# Limit the amount of results you get back |
||||
|
limit: Int |
||||
|
} |
||||
|
|
||||
|
# Input for addLog mutation |
||||
|
input LogAddInput { |
||||
|
# The date of the log. |
||||
|
date: Date! |
||||
|
|
||||
|
# The channel where the log is set |
||||
|
channel: String! |
||||
|
|
||||
|
# Optional: The log title |
||||
|
title: String |
||||
|
|
||||
|
# Optional: Whether the log is open |
||||
|
open: Boolean |
||||
|
|
||||
|
# Optional: The log event name |
||||
|
event: String |
||||
|
|
||||
|
# Optional: A short description of the log |
||||
|
description: String |
||||
|
} |
||||
|
|
||||
|
# Input for addLog mutation |
||||
|
input LogEditInput { |
||||
|
# The id of the log |
||||
|
id: String! |
||||
|
|
||||
|
# The log title |
||||
|
title: String |
||||
|
|
||||
|
# The log event name |
||||
|
event: String |
||||
|
|
||||
|
# A short description of the log |
||||
|
description: String |
||||
|
|
||||
|
# Open/close the log |
||||
|
open: Boolean |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue