public override IEnumerable <Series> Run(Collector collector)
        {
            var collectorTyped = collector as StartingWithCollector;

            if (collectorTyped == null)
            {
                yield return(null);
            }

            var currentTime = DateTime.UtcNow;
            var store       = RavenHelper.CreateStore(collectorTyped.Source.Url, collectorTyped.Source.Database);

            FacetResults results;

            using (var session = store.OpenSession()) {
                results = session.Query <RavenJObject>("Raven/DocumentsByEntityName")
                          .Where(x => ((string)x.Tag).StartsWith(collectorTyped.StartingWith))
                          .AggregateBy(x => x.Tag)
                          .CountOn(x => x.Tag)
                          .ToList();
            }

            foreach (var result in results.Results["Tag"].Values)
            {
                var series = new Series {
                    Id    = Series.CreateId(result.Range, collectorTyped.GroupName, currentTime),
                    Tag   = result.Range,
                    Group = collectorTyped.GroupName,
                    Time  = currentTime,
                    Value = result.Count.ToString()
                };

                yield return(series);
            }
        }
        public override IEnumerable <Series> Run(Collector collector)
        {
            var collectorTyped = collector as CollectionCollector;

            if (collectorTyped == null)
            {
                yield return(null);
            }

            var currentTime = DateTime.UtcNow;
            var store       = RavenHelper.CreateStore(collectorTyped.Source.Url, collectorTyped.Source.Database);

            int result = 0;

            using (var session = store.OpenSession()) {
                result = session.Advanced
                         .DocumentQuery <RavenJObject>("Raven/DocumentsByEntityName")
                         .WhereEquals("Tag", collectorTyped.CollectionName)
                         .Count();
            }

            var series = new Series {
                Id    = Series.CreateId(collectorTyped.CollectionName, collectorTyped.GroupName, currentTime),
                Tag   = collectorTyped.CollectionName,
                Group = collectorTyped.GroupName,
                Time  = currentTime,
                Value = result.ToString()
            };

            yield return(series);
        }