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.

32 lines
594 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. collection.EnsureIndexKey("keys")
  17. err := collection.EnsureIndex(mgo.Index{
  18. Name: "expiry",
  19. Key: []string{"date"},
  20. ExpireAfter: time.Hour * 2400, // 100 days
  21. })
  22. if err != nil {
  23. log.Fatalln(err)
  24. }
  25. })
  26. }