// Trends calculate trends from a query
Trends calculate trends from a query
// Trends calculate trends from a query
func (d *MongoDB) Trends(q xlog.Query) (rs []xlog.Trend, err error) {
	coll := d.Collection(q.Timestamp.Beginning)
	qs := q.TrendQueries()
	rs = make([]xlog.Trend, 0, len(qs))
	for _, tq := range qs {
		var c int
		if c, err = coll.Find(tq.ToMatch()).SetMaxTime(time.Second * 10).Count(); err != nil {
			return
		}
		rs = append(rs, xlog.Trend{
			Beginning: tq.Timestamp.Beginning,
			End:       tq.Timestamp.End,
			Count:     c,
		})
	}
	return
}
func ( d * MongoDB ) Trends ( q xlog . Query ) ( rs [ ] xlog . Trend , err error ) { coll := d . Collection ( q . Timestamp . Beginning ) qs := q . TrendQueries ( ) rs = make ( [ ] xlog . Trend , 0 , len ( qs ) ) for _ , tq := range qs { var c int if c , err = coll . Find ( tq . ToMatch ( ) ) . SetMaxTime ( time . Second * 10 ) . Count ( ) ; err != nil { return } rs = append ( rs , xlog . Trend { Beginning : tq . Timestamp . Beginning , End : tq . Timestamp . End , Count : c , } ) } return }
Trends calculate trends from a query
Trends calculate trends from a query
// trend queries