The new logbot, not committed from the wrong terminal window this time.
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.

31 lines
675 B

  1. package models
  2. import "time"
  3. // A Log represents a log session.
  4. type Log struct {
  5. ID string `json:"id"`
  6. Date time.Time `json:"date"`
  7. ChannelName string `json:"channelName"`
  8. Title string `json:"title"`
  9. EventName string `json:"eventName"`
  10. Description string `json:"description"`
  11. Open bool `json:"open"`
  12. Posts []Post `json:"posts"`
  13. }
  14. // LatestTime gets the latest timestamp in the log.
  15. func (log *Log) LatestTime() time.Time {
  16. if len(log.Posts) == 0 {
  17. return log.Date
  18. }
  19. latest := log.Date
  20. for _, post := range log.Posts {
  21. if post.Time.After(latest) {
  22. latest = post.Time
  23. }
  24. }
  25. return latest
  26. }