Add search terms to the moderation page

* Closes: #22
This commit is contained in:
Las Zenow 2017-02-04 01:28:10 +00:00
parent fcf9b1eb8d
commit 8e82ee3702
5 changed files with 26 additions and 15 deletions

View file

@ -91,11 +91,15 @@ func addBook(coll *mgo.Collection, book map[string]interface{}) error {
}
func getBooks(coll *mgo.Collection, query string, length int, start int) (books []Book, num int, err error) {
return _getBooks(coll, buildQuery(query), length, start)
q := buildQuery(query)
q["active"] = true
return _getBooks(coll, q, length, start)
}
func getNewBooks(coll *mgo.Collection, length int, start int) (books []Book, num int, err error) {
return _getBooks(coll, bson.M{"$nor": []bson.M{{"active": true}}}, length, start)
func getNewBooks(coll *mgo.Collection, query string, length int, start int) (books []Book, num int, err error) {
q := buildQuery(query)
q["$nor"] = []bson.M{{"active": true}}
return _getBooks(coll, q, length, start)
}
func getBooksIter(coll *mgo.Collection) Iter {
@ -193,7 +197,7 @@ func isBookActive(coll *mgo.Collection, id string) bool {
func buildQuery(q string) bson.M {
text := ""
query := bson.M{"active": true}
query := bson.M{}
words := strings.Split(q, " ")
for _, w := range words {
tag := strings.SplitN(w, ":", 2)