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.

31 lines
558 B

  1. package changes
  2. import (
  3. "log"
  4. "sync"
  5. "time"
  6. "git.aiterp.net/rpdata/api/internal/store"
  7. "github.com/globalsign/mgo"
  8. )
  9. var collection *mgo.Collection
  10. var submitMutex sync.Mutex
  11. func init() {
  12. store.HandleInit(func(db *mgo.Database) {
  13. collection = db.C("common.changes")
  14. collection.EnsureIndexKey("date")
  15. collection.EnsureIndexKey("author")
  16. err := collection.EnsureIndex(mgo.Index{
  17. Name: "expiry",
  18. Key: []string{"date"},
  19. ExpireAfter: time.Hour * 2400, // 100 days
  20. })
  21. if err != nil {
  22. log.Fatalln(err)
  23. }
  24. })
  25. }