GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6 KiB

  1. package models
  2. import "time"
  3. // Log is the header/session for a log file.
  4. type Log struct {
  5. ID string `bson:"_id"`
  6. ShortID string `bson:"shortId"`
  7. Date time.Time `bson:"date"`
  8. ChannelName string `bson:"channel"`
  9. EventName string `bson:"event,omitempty"`
  10. Title string `bson:"title,omitempty"`
  11. Description string `bson:"description,omitempty"`
  12. Open bool `bson:"open"`
  13. CharacterIDs []string `bson:"characterIds"`
  14. }
  15. func (log *Log) ApplyUpdate(update LogUpdate) {
  16. if update.Open != nil {
  17. log.Open = *update.Open
  18. }
  19. if update.EventName != nil {
  20. log.EventName = *update.EventName
  21. }
  22. if update.Title != nil {
  23. log.Title = *update.Title
  24. }
  25. if update.Description != nil {
  26. log.Description = *update.Description
  27. }
  28. if update.CharacterIDs != nil {
  29. log.CharacterIDs = update.CharacterIDs
  30. }
  31. }
  32. // A LogSuggestion is a suggestion for a log.
  33. type LogSuggestion struct {
  34. Log *Log
  35. Characters []*Character
  36. HasChannel bool
  37. HasEvent bool
  38. }
  39. // IsChangeObject is an interface implementation to identify it as a valid
  40. // ChangeObject in GQL.
  41. func (*Log) IsChangeObject() {
  42. panic("this method is a dummy, and so is its caller")
  43. }
  44. // A LogFilter is a filter that can be used to list logs.
  45. type LogFilter struct {
  46. Open *bool
  47. Characters []string
  48. Channels []string
  49. Events []string
  50. MinDate *time.Time
  51. MaxDate *time.Time
  52. Search *string
  53. Limit int
  54. }
  55. type LogUpdate struct {
  56. Title *string
  57. EventName *string
  58. Description *string
  59. Open *bool
  60. CharacterIDs []string
  61. }